Remove the call to wxversion.py on winbuilder, because it does not work (not found, even when exists), ans it is not useful. Avoid crashes when wxPython scripting layer is not loaded, on kicad exit, and when trying to open the py console.

This commit is contained in:
jean-pierre charras 2015-07-09 18:44:23 +02:00
parent f0a1f6dd78
commit 01ae08a9a9
3 changed files with 28 additions and 10 deletions

View File

@ -59,6 +59,7 @@
#include <modview_frame.h>
#include <footprint_wizard_frame.h>
extern bool IsWxPythonLoaded();
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings;
@ -285,9 +286,11 @@ static bool scriptingSetup()
path_frag = wxT( "/usr/local/kicad/bin/scripting/plugins" );
#endif
if( !pcbnewInitPythonScripting( TO_UTF8( path_frag ) ) )
pcbnewInitPythonScripting( TO_UTF8( path_frag ) );
if( !IsWxPythonLoaded() )
{
wxLogSysError( wxT( "pcbnewInitPythonScripting() failed." ) );
wxLogError( wxT( "pcbnewInitPythonScripting() failed." ) );
return false;
}
@ -361,6 +364,7 @@ void IFACE::OnKifaceEnd()
// wxPython will do its own cleanup as part of that process.
// This should only be called if python was setup correctly.
if( IsWxPythonLoaded() )
pcbnewFinishPythonScripting();
#endif
}

View File

@ -46,6 +46,8 @@
#include <wx/wupdlock.h>
extern bool IsWxPythonLoaded();
#define SEL_LAYER_HELP _( \
"Show active layer selections\nand select layer pair for route and place via" )
@ -303,12 +305,15 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
// Access to the scripting console
#if defined(KICAD_SCRIPTING_WXPYTHON)
if( IsWxPythonLoaded() )
{
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
KiBitmap( py_script_xpm ),
_( "Show/Hide the Python Scripting console" ),
wxITEM_CHECK );
}
#endif
// after adding the buttons to the toolbar, must call Realize() to reflect the changes

View File

@ -55,6 +55,13 @@ extern "C" void init_pcbnew( void );
struct _inittab* SwigImportInittab;
static int SwigNumModules = 0;
static bool wxPythonLoaded = false; // true if the wxPython scripting layer was successfully loaded
bool IsWxPythonLoaded()
{
return wxPythonLoaded;
}
/* Add a name + initfuction to our SwigImportInittab */
@ -140,6 +147,7 @@ bool pcbnewInitPythonScripting( const char * aUserPluginsPath )
#ifdef KICAD_SCRIPTING_WXPYTHON
PyEval_InitThreads();
#ifndef __WINDOWS__ // import wxversion.py currently not working under winbuilder, and not useful.
char cmd[1024];
// Make sure that that the correct version of wxPython is loaded. In systems where there
// are different versions of wxPython installed this can lead to select wrong wxPython
@ -155,6 +163,7 @@ bool pcbnewInitPythonScripting( const char * aUserPluginsPath )
Py_Finalize();
return false;
}
#endif // ifndef __WINDOWS__
// 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
@ -171,8 +180,8 @@ bool pcbnewInitPythonScripting( const char * aUserPluginsPath )
// Global Interpreter Lock.
g_PythonMainTState = wxPyBeginAllowThreads();
#endif // ifdef KICAD_SCRIPTING_WXPYTHON
#endif
// load pcbnew inside python, and load all the user plugins, TODO: add system wide plugins
{
char cmd[1024];