python: Fix Phoenix app setting
Phoenix doesn't have the same initialization as wxpython3 and so the namespace doesn't get the wxApp() initialized to the existing instance. In python, this is worked around by starting a new wxApp. Unfortunately, this appears to overwrite the existing global instance variable. The issue _appears_ to be in Phoenix but for now we work around it by saving and resetting the instance pointer in the main app. The downside is that Python likely won't be able to respond to events from C++ Fixes: lp:1809913 * https://bugs.launchpad.net/kicad/+bug/1809913
This commit is contained in:
parent
3ea766154b
commit
8b060799eb
|
@ -366,9 +366,16 @@ wxWindow* CreatePythonShellWindow( wxWindow* parent, const wxString& aFramenameI
|
||||||
PyDict_SetItemString( globals, "__builtins__", builtins );
|
PyDict_SetItemString( globals, "__builtins__", builtins );
|
||||||
Py_DECREF( builtins );
|
Py_DECREF( builtins );
|
||||||
|
|
||||||
|
auto app_ptr = wxTheApp;
|
||||||
// Execute the code to make the makeWindow function we defined above
|
// Execute the code to make the makeWindow function we defined above
|
||||||
PyObject* result = PyRun_String( pcbnew_pyshell_one_step.str().c_str(), Py_file_input, globals, globals );
|
PyObject* result = PyRun_String( pcbnew_pyshell_one_step.str().c_str(), Py_file_input, globals, globals );
|
||||||
|
|
||||||
|
#ifdef KICAD_SCRIPTING_WXPYTHON_PHOENIX
|
||||||
|
// This absolutely ugly hack is to work around the pyshell re-writing the global
|
||||||
|
// wxApp variable. Once we can initialize Phoenix to access the appropriate instance
|
||||||
|
// of wx, we can remove this line
|
||||||
|
wxApp::SetInstance( app_ptr );
|
||||||
|
#endif
|
||||||
// Was there an exception?
|
// Was there an exception?
|
||||||
if( !result )
|
if( !result )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue