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:
+13
-16
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user