Minor wxPython scripting improvements.
* Wrap Pgm().OnPgmExit() changes in APP_SINGLE_TOP to build conditionally when KICAD_SCRIPTING_WXPYTHON is enabled. * Check the result of loading the correct wxPython version during initialization.
This commit is contained in:
parent
7be1d32a10
commit
c288d200fb
|
@ -143,8 +143,10 @@ struct APP_SINGLE_TOP : public wxApp
|
||||||
|
|
||||||
int OnExit() // overload wxApp virtual
|
int OnExit() // overload wxApp virtual
|
||||||
{
|
{
|
||||||
|
// Fixes segfault when wxPython scripting is enabled.
|
||||||
|
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
||||||
Pgm().OnPgmExit();
|
Pgm().OnPgmExit();
|
||||||
|
#endif
|
||||||
return wxApp::OnExit();
|
return wxApp::OnExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +173,11 @@ struct APP_SINGLE_TOP : public wxApp
|
||||||
wxLogError( wxT( "Unhandled exception of unknown type" ) );
|
wxLogError( wxT( "Unhandled exception of unknown type" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Works properly when wxPython scripting is disabled.
|
||||||
|
#if !defined( KICAD_SCRIPTING_WXPYTHON )
|
||||||
|
Pgm().OnPgmExit();
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,8 +288,9 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
||||||
// We've already initialized things at this point, but wx won't call OnExit if
|
// We've already initialized things at this point, but wx won't call OnExit if
|
||||||
// we fail out. Call our own cleanup routine here to ensure the relevant resources
|
// we fail out. Call our own cleanup routine here to ensure the relevant resources
|
||||||
// are freed at the right time (if they aren't, segfaults will occur).
|
// are freed at the right time (if they aren't, segfaults will occur).
|
||||||
|
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
||||||
OnPgmExit();
|
OnPgmExit();
|
||||||
|
#endif
|
||||||
// Fail the process startup if the file could not be opened,
|
// Fail the process startup if the file could not be opened,
|
||||||
// although this is an optional choice, one that can be reversed
|
// although this is an optional choice, one that can be reversed
|
||||||
// also in the KIFACE specific OpenProjectFiles() return value.
|
// also in the KIFACE specific OpenProjectFiles() return value.
|
||||||
|
|
|
@ -145,7 +145,16 @@ bool pcbnewInitPythonScripting( const char * aUserPluginsPath )
|
||||||
// are different versions of wxPython installed this can lead to select wrong wxPython
|
// are different versions of wxPython installed this can lead to select wrong wxPython
|
||||||
// version being selected.
|
// version being selected.
|
||||||
snprintf( cmd, sizeof(cmd), "import wxversion; wxversion.select('%s')", WXPYTHON_VERSION );
|
snprintf( cmd, sizeof(cmd), "import wxversion; wxversion.select('%s')", WXPYTHON_VERSION );
|
||||||
PyRun_SimpleString( cmd );
|
|
||||||
|
int retv = PyRun_SimpleString( cmd );
|
||||||
|
|
||||||
|
if( retv != 0 )
|
||||||
|
{
|
||||||
|
wxLogError( wxT( "Python error %d occurred running string `%s`" ), retv, cmd );
|
||||||
|
PyErr_Print();
|
||||||
|
Py_Finalize();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Load the wxPython core API. Imports the wx._core_ module and sets a
|
// Load the wxPython core API. Imports the wx._core_ module and sets a
|
||||||
// local pointer to a function table located there. The pointer is used
|
// local pointer to a function table located there. The pointer is used
|
||||||
|
|
Loading…
Reference in New Issue