Kicad: fix environment variable changes after running Pcbnew in some cases.

When pcbnew is built with python support, the env vars defined inside Kicad
(and used mainly in paths) are rewritten for the python environment.
Unfortunately, the values are rewritten as UTF8 string, but in Kicad they are
just expected in utf32 unicode values.

This is now fixed by rewriting the initial values in Kicad env, after the
python environment is initialized.
This commit is contained in:
jean-pierre charras 2020-11-18 17:33:58 +01:00
parent f19440f72e
commit d3a72f73e3
1 changed files with 11 additions and 0 deletions

View File

@ -1503,8 +1503,15 @@ void PCB_EDIT_FRAME::PythonSyncEnvironmentVariables()
#if defined( KICAD_SCRIPTING )
const ENV_VAR_MAP& vars = Pgm().GetLocalEnvVariables();
// Set the environment variables for python scripts
// note: the strint will be encoded UTF8 for python env
for( auto& var : vars )
pcbnewUpdatePythonEnvVar( var.first, var.second.GetValue() );
// Because the env vars can de modifed by the python scripts (rewritten in UTF8),
// regenerate them (in unicode) for our normal environment
for( auto& var : vars )
wxSetEnv( var.first, var.second.GetValue() );
#endif
}
@ -1515,6 +1522,10 @@ void PCB_EDIT_FRAME::PythonSyncProjectName()
wxString evValue;
wxGetEnv( PROJECT_VAR_NAME, &evValue );
pcbnewUpdatePythonEnvVar( wxString( PROJECT_VAR_NAME ).ToStdString(), evValue );
// Because PROJECT_VAR_NAME can be modifed by the python scripts (rewritten in UTF8),
// regenerate it (in unicode) for our normal environment
wxSetEnv( PROJECT_VAR_NAME, evValue );
#endif
}