Fix user configuration path bug on Linux.
Recent versions of wxWidgets wxStandardPaths::GetUserConfigDir() correctly append ".config" on Linux build which was incorrect as the current code already appended it to the path. Add a check to see if ".config" is the last path and append as required. Check for XDG_CONFIG_HOME environment variable on all platforms not just Linux. Fixes lp:1769145 https://bugs.launchpad.net/kicad/+bug/1769145
This commit is contained in:
parent
dbc2eea3db
commit
5c5b74b29e
|
@ -2,8 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
@ -58,14 +58,6 @@ EDA_UNITS_T g_UserUnit;
|
|||
COLOR4D g_GhostColor;
|
||||
|
||||
|
||||
/* Class LOCALE_IO
|
||||
* is a class that can be instantiated within a scope in which you are expecting
|
||||
* exceptions to be thrown. Its constructor sets a "C" locale, to read/print files
|
||||
* with fp numbers.
|
||||
* Its destructor insures that the default locale is restored if an exception
|
||||
* is thrown, or not.
|
||||
*/
|
||||
|
||||
std::atomic<unsigned int> LOCALE_IO::m_c_count(0);
|
||||
|
||||
LOCALE_IO::LOCALE_IO()
|
||||
|
@ -80,6 +72,7 @@ LOCALE_IO::LOCALE_IO()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
LOCALE_IO::~LOCALE_IO()
|
||||
{
|
||||
// use thread safe, atomic operation
|
||||
|
@ -222,20 +215,24 @@ wxString GetKicadConfigPath()
|
|||
// http://docs.wxwidgets.org/3.0/classwx_standard_paths.html#a7c7cf595d94d29147360d031647476b0
|
||||
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
|
||||
|
||||
// GetUserConfigDir() does not default to ~/.config which is the current standard
|
||||
// configuration file location on Linux. This has been fixed in later versions of wxWidgets.
|
||||
#if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
|
||||
wxArrayString dirs = cfgpath.GetDirs();
|
||||
|
||||
if( dirs.Last() != ".config" )
|
||||
cfgpath.AppendDir( ".config" );
|
||||
#endif
|
||||
|
||||
wxString envstr;
|
||||
|
||||
// wxStandardPaths does not default to ~/.config which is the current standard config
|
||||
// location on Linux. This has been fixed in wxWidgets 3.1.1.
|
||||
#if !wxCHECK_VERSION( 3, 1, 1 ) && !defined( __WINDOWS__ ) && !defined( __WXMAC__ )
|
||||
// This shouldn't cause any issues on Windows or MacOS.
|
||||
if( wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
|
||||
{
|
||||
// Override the assignment above with XDG_CONFIG_HOME
|
||||
cfgpath.AssignDir( envstr );
|
||||
}
|
||||
|
||||
cfgpath.AppendDir( wxT( ".config" ) );
|
||||
#endif
|
||||
|
||||
cfgpath.AppendDir( wxT( "kicad" ) );
|
||||
|
||||
// Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
*
|
||||
* Copyright (C) 2014-2017 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-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 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
|
||||
|
@ -94,9 +94,8 @@ enum pseudokeys {
|
|||
//-----<KiROUND KIT>------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* KiROUND
|
||||
* rounds a floating point number to an int using
|
||||
* "round halfway cases away from zero".
|
||||
* Round a floating point number to an integer using "round halfway cases away from zero".
|
||||
*
|
||||
* In Debug build an assert fires if will not fit into an int.
|
||||
*/
|
||||
|
||||
|
@ -122,11 +121,13 @@ static inline int kiRound_( double v, int line, const char* filename )
|
|||
v = v < 0 ? v - 0.5 : v + 0.5;
|
||||
if( v > INT_MAX + 0.5 )
|
||||
{
|
||||
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
|
||||
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n",
|
||||
__FUNCTION__, filename, line, v );
|
||||
}
|
||||
else if( v < INT_MIN - 0.5 )
|
||||
{
|
||||
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
|
||||
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n",
|
||||
__FUNCTION__, filename, line, v );
|
||||
}
|
||||
return int( v );
|
||||
}
|
||||
|
@ -156,12 +157,12 @@ extern KIGFX::COLOR4D g_GhostColor;
|
|||
|
||||
|
||||
/**
|
||||
* Class LOCALE_IO
|
||||
* is a class that can be instantiated within a scope in which you are expecting
|
||||
* exceptions to be thrown. Its constructor set a "C" laguage locale option,
|
||||
* to read/print files with fp numbers.
|
||||
* Its destructor insures that the default locale is restored if an exception
|
||||
* is thrown, or not.
|
||||
* Instantiate the current locale within a scope in which you are expecting
|
||||
* exceptions to be thrown.
|
||||
*
|
||||
* The constructor sets a "C" language locale option, to read/print files with floating
|
||||
* point numbers. The destructor insures that the default locale is restored if an
|
||||
* exception is thrown or not.
|
||||
*/
|
||||
class LOCALE_IO
|
||||
{
|
||||
|
@ -180,21 +181,20 @@ private:
|
|||
std::string m_user_locale;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function GetTextSize
|
||||
* returns the size of @a aSingleLine of text when it is rendered in @a aWindow
|
||||
* Return the size of @a aSingleLine of text when it is rendered in @a aWindow
|
||||
* using whatever font is currently set in that window.
|
||||
*/
|
||||
wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
|
||||
|
||||
/**
|
||||
* Function EnsureTextCtrlWidth
|
||||
* sets the minimum pixel width on a text control in order to make a text
|
||||
* string be fully visible within it. The current font within the text
|
||||
* control is considered.
|
||||
* The text can come either from the control or be given as an argument.
|
||||
* If the text control is larger than needed, then nothing is done.
|
||||
* Set the minimum pixel width on a text control in order to make a text
|
||||
* string be fully visible within it.
|
||||
*
|
||||
* The current font within the text control is considered. The text can come either from
|
||||
* the control or be given as an argument. If the text control is larger than needed, then
|
||||
* nothing is done.
|
||||
*
|
||||
* @param aCtrl the text control to potentially make wider.
|
||||
* @param aString the text that is used in sizing the control's pixel width.
|
||||
* If NULL, then
|
||||
|
@ -203,10 +203,9 @@ wxSize GetTextSize( const wxString& aSingleLine, wxWindow* aWindow );
|
|||
*/
|
||||
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
||||
|
||||
|
||||
/**
|
||||
* Function ProcessExecute
|
||||
* runs a child process.
|
||||
* Run a command in a child process.
|
||||
*
|
||||
* @param aCommandLine The process and any arguments to it all in a single
|
||||
* string.
|
||||
* @param aFlags The same args as allowed for wxExecute()
|
||||
|
@ -218,7 +217,6 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
|
|||
int ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC,
|
||||
wxProcess *callback = NULL );
|
||||
|
||||
|
||||
/**
|
||||
* @return an unique time stamp that changes after each call
|
||||
*/
|
||||
|
@ -239,8 +237,8 @@ int GetCommandOptions( const int argc, const char** argv,
|
|||
double RoundTo0( double x, double precision );
|
||||
|
||||
/**
|
||||
* Function wxStringSplit
|
||||
* splits \a aString to a string list separated at \a aSplitter.
|
||||
* Split \a aString to a string list separated at \a aSplitter.
|
||||
*
|
||||
* @param aText is the text to split
|
||||
* @param aStrings will contain the splitted lines
|
||||
* @param aSplitter is the 'split' character
|
||||
|
@ -248,8 +246,7 @@ double RoundTo0( double x, double precision );
|
|||
void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSplitter );
|
||||
|
||||
/**
|
||||
* Function SearchHelpFileFullPath
|
||||
* returns the help file's full path.
|
||||
* Return the help file's full path.
|
||||
* <p>
|
||||
* Return the KiCad help file with path and extension.
|
||||
* Help files can be html (.html ext) or pdf (.pdf ext) files.
|
||||
|
@ -270,27 +267,26 @@ void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSpli
|
|||
wxString SearchHelpFileFullPath( const SEARCH_STACK& aSearchStack, const wxString& aBaseName );
|
||||
|
||||
/**
|
||||
* Helper function EnsureFileDirectoryExists
|
||||
* make \a aTargetFullFileName absolute and creates the path of this file if it doesn't yet exist.
|
||||
* @param aTargetFullFileName the wxFileName containing the full path and file name to modify. The path
|
||||
* may be absolute or relative to \a aBaseFilename .
|
||||
* Make \a aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
|
||||
*
|
||||
* @param aTargetFullFileName the wxFileName containing the full path and file name to modify.
|
||||
* The path may be absolute or relative to \a aBaseFilename .
|
||||
* @param aBaseFilename a full filename. Only its path is used to set the aTargetFullFileName path.
|
||||
* @param aReporter a point to a REPORTER object use to show messages (can be NULL)
|
||||
* @return true if \a aOutputDir already exists or was successfully created.
|
||||
*/
|
||||
bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName,
|
||||
const wxString& aBaseFilename,
|
||||
REPORTER* aReporter = NULL );
|
||||
const wxString& aBaseFilename,
|
||||
REPORTER* aReporter = NULL );
|
||||
|
||||
/// Put aPriorityPath in front of all paths in the value of aEnvVar.
|
||||
const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPath );
|
||||
|
||||
/**
|
||||
* Function GetNewConfig
|
||||
* Create a new wxConfig so we can put configuration files in a more proper place for each
|
||||
* platform.
|
||||
*
|
||||
* Use this function instead of creating a new wxConfig so we can put config files in
|
||||
* a more proper place for each platform. This is generally $HOME/.config/kicad/ in Linux
|
||||
* according to the FreeDesktop specification at
|
||||
* This is generally $HOME/.config/kicad/ in Linux according to the FreeDesktop specification at
|
||||
* http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
|
||||
* The config object created here should be destroyed by the caller.
|
||||
*
|
||||
|
@ -301,25 +297,30 @@ const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPa
|
|||
*/
|
||||
wxConfigBase* GetNewConfig( const wxString& aProgName );
|
||||
|
||||
|
||||
/**
|
||||
* Function GetKicadConfigPath
|
||||
* Return the user configuration path used to store KiCad's configuration files.
|
||||
*
|
||||
* The configuration path order of precedence is determined by the following criteria:
|
||||
*
|
||||
* - The value of the KICAD_CONFIG_HOME environment variable
|
||||
* - The value of the XDG_CONFIG_HOME environment variable.
|
||||
* - The result of the call to wxStandardPaths::GetUserConfigDir() with ".config" appended
|
||||
* as required on Linux builds.
|
||||
*
|
||||
* @return A wxString containing the config path for Kicad
|
||||
*/
|
||||
wxString GetKicadConfigPath();
|
||||
|
||||
/**
|
||||
* Function ExpandEnvVarSubstitutions
|
||||
* replaces any environment variable references with their values
|
||||
* Replace any environment variable references with their values.
|
||||
*
|
||||
* @param aString = a string containing (perhaps) references to env var
|
||||
* @return a string where env var are replaced by their value
|
||||
*/
|
||||
const wxString ExpandEnvVarSubstitutions( const wxString& aString );
|
||||
|
||||
/**
|
||||
* Function ResolveUriByEnvVars
|
||||
* replaces any environment variables in file-path uris (leaving network-path
|
||||
* uris alone).
|
||||
* Replace any environment variables in file-path uris (leaving network-path URIs alone).
|
||||
*/
|
||||
const wxString ResolveUriByEnvVars( const wxString& aUri );
|
||||
|
||||
|
|
Loading…
Reference in New Issue