Fix environment variable initialization issue on Linux. (fixes lp:1550620)

* Linux environment variables are not initialized properly if the value
  contains any non ASCII7 characters and if the locale is not set.  Set
  the locale before reading the environment variable configuration.
This commit is contained in:
jean-pierre charras 2016-03-01 08:53:19 -05:00 committed by Wayne Stambaugh
parent 79fe4a0acb
commit 6d3e1b9391
1 changed files with 29 additions and 18 deletions

View File

@ -481,10 +481,13 @@ bool PGM_BASE::initPgm()
ReadPdfBrowserInfos(); // needs m_common_settings
loadCommonSettings();
// Init user language *before* calling loadCommonSettings, because
// env vars could be incorrectly initialized on Linux
// (if the value contains some non ASCII7 chars, the env var is not initialized)
SetLanguage( true );
loadCommonSettings();
// Set locale option for separator used in float numbers
SetLocaleTo_Default();
@ -546,23 +549,8 @@ void PGM_BASE::loadCommonSettings()
m_help_size.x = 500;
m_help_size.y = 400;
wxString languageSel;
m_common_settings->Read( languageCfgKey, &languageSel );
setLanguageId( wxLANGUAGE_DEFAULT );
m_common_settings->Read( showEnvVarWarningDialog, &m_show_env_var_dialog );
// Search for the current selection
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( s_Languages[ii].m_Lang_Label == languageSel )
{
setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
break;
}
}
m_editor_name = m_common_settings->Read( wxT( "Editor" ) );
wxString entry, oldPath;
@ -622,6 +610,26 @@ bool PGM_BASE::SetLanguage( bool first_time )
{
bool retv = true;
if( first_time )
{
setLanguageId( wxLANGUAGE_DEFAULT );
// First time SetLanguage is called, the user selected language id is set
// from commun user config settings
wxString languageSel;
m_common_settings->Read( languageCfgKey, &languageSel );
// Search for the current selection
for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
{
if( s_Languages[ii].m_Lang_Label == languageSel )
{
setLanguageId( s_Languages[ii].m_WX_Lang_Identifier );
break;
}
}
}
// dictionary file name without extend (full name is kicad.mo)
wxString dictionaryName( wxT( "kicad" ) );
@ -645,9 +653,12 @@ bool PGM_BASE::SetLanguage( bool first_time )
GetChars( dictionaryName ), GetChars( m_locale->GetName() ) );
}
// how about a meaningful comment here.
if( !first_time )
{
// If we are here, the user has selected an other language.
// Therefore the new prefered language name is stored in common config.
// Do NOT store the wxWidgets language Id, it can change between wxWidgets
// versions, for a given language
wxString languageSel;
// Search for the current selection