Use XDG_CONFIG_DIR for lock file path on Linux.
* With fixes from Adam Wolf.
This commit is contained in:
parent
547c145a1e
commit
c9a1b239a6
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -271,9 +271,9 @@ double RoundTo0( double x, double precision )
|
|||
|
||||
int remainder = ix % 10; // remainder is in precision mm
|
||||
|
||||
if ( remainder <= 2 )
|
||||
if( remainder <= 2 )
|
||||
ix -= remainder; // truncate to the near number
|
||||
else if (remainder >= 8 )
|
||||
else if( remainder >= 8 )
|
||||
ix += 10 - remainder; // round to near number
|
||||
|
||||
if ( x < 0 )
|
||||
|
@ -305,6 +305,46 @@ wxConfigBase* GetNewConfig( const wxString& aProgName )
|
|||
return cfg;
|
||||
}
|
||||
|
||||
wxString GetKicadLockFilePath()
|
||||
{
|
||||
wxFileName lockpath;
|
||||
lockpath.AssignDir( wxGetHomeDir() ); // Default wx behavior
|
||||
|
||||
#if defined( __WXMAC__ )
|
||||
// In OSX use the standard per user cache directory
|
||||
lockpath.AppendDir( wxT( "Library" ) );
|
||||
lockpath.AppendDir( wxT( "Caches" ) );
|
||||
lockpath.AppendDir( wxT( "kicad" ) );
|
||||
#elif defined( __UNIX__ )
|
||||
wxString envstr;
|
||||
// Try first the standard XDG_RUNTIME_DIR, falling back to XDG_CACHE_HOME
|
||||
if( wxGetEnv( wxT( "XDG_RUNTIME_DIR" ), &envstr ) && !envstr.IsEmpty() )
|
||||
{
|
||||
lockpath.AssignDir( envstr );
|
||||
}
|
||||
else if( wxGetEnv( wxT( "XDG_CACHE_HOME" ), &envstr ) && !envstr.IsEmpty() )
|
||||
{
|
||||
lockpath.AssignDir( envstr );
|
||||
}
|
||||
else
|
||||
{
|
||||
// If all fails, just use ~/.cache
|
||||
lockpath.AppendDir( wxT( ".cache" ) );
|
||||
}
|
||||
|
||||
lockpath.AppendDir( wxT( "kicad" ) );
|
||||
#endif
|
||||
|
||||
#if defined( __WXMAC__ ) || defined( __UNIX__ )
|
||||
if( !lockpath.DirExists() )
|
||||
{
|
||||
// Lockfiles should be only readable by the user
|
||||
lockpath.Mkdir( 0700, wxPATH_MKDIR_FULL );
|
||||
}
|
||||
#endif
|
||||
return lockpath.GetPath();
|
||||
}
|
||||
|
||||
|
||||
wxString GetKicadConfigPath()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2014-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <common.h>
|
||||
|
||||
|
||||
wxSingleInstanceChecker* LockFile( const wxString& aFileName )
|
||||
|
@ -41,7 +42,8 @@ wxSingleInstanceChecker* LockFile( const wxString& aFileName )
|
|||
// We can have filenames coming from Windows, so also convert Windows separator
|
||||
lockFileName.Replace( wxT( "\\" ), wxT( "_" ) );
|
||||
|
||||
wxSingleInstanceChecker* p = new wxSingleInstanceChecker( lockFileName );
|
||||
wxSingleInstanceChecker* p = new wxSingleInstanceChecker( lockFileName,
|
||||
GetKicadLockFilePath() );
|
||||
|
||||
if( p->IsAnotherRunning() )
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -353,7 +353,7 @@ bool PGM_BASE::initPgm()
|
|||
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() );
|
||||
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId(), GetKicadLockFilePath() );
|
||||
|
||||
if( m_pgm_checker->IsAnotherRunning() )
|
||||
{
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -278,7 +278,7 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
|||
* wxExecute())
|
||||
*/
|
||||
int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC,
|
||||
wxProcess *callback = NULL );
|
||||
wxProcess *callback = NULL );
|
||||
|
||||
|
||||
/*******************/
|
||||
|
@ -433,6 +433,12 @@ const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPa
|
|||
*/
|
||||
wxConfigBase* GetNewConfig( const wxString& aProgName );
|
||||
|
||||
/**
|
||||
* Function GetKicadLockFilePath
|
||||
* @return A wxString containing the path for lockfiles in Kicad
|
||||
*/
|
||||
wxString GetKicadLockFilePath();
|
||||
|
||||
/**
|
||||
* Function GetKicadConfigPath
|
||||
* @return A wxString containing the config path for Kicad
|
||||
|
|
Loading…
Reference in New Issue