diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index ee85356494..7ee768d8f7 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -136,7 +136,10 @@ protected: * Refresh plugin list (reload Python plugins) * @param aEvent sent by wx */ - void OnActionPluginRefresh( wxCommandEvent& aEvent); + void OnActionPluginRefresh( wxCommandEvent& aEvent) + { + PythonPluginsReload(); + } #endif /** Has meaning only if KICAD_SCRIPTING_WXPYTHON option is diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 7bc029d3cf..351ccabd0f 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include <3d_viewer/eda_3d_viewer.h> #include #include @@ -721,7 +722,6 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar() } #if defined(KICAD_SCRIPTING) -#include void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload() { // Reload the Python plugins @@ -734,14 +734,7 @@ void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload() if( brd_frame ) brd_frame->PythonPluginsReload(); else - { - char cmd[1024]; - snprintf( cmd, sizeof(cmd), - "pcbnew.LoadPlugins(\"%s\")", TO_UTF8( PyScriptingPath() ) ); - PyLOCK lock; - // ReRun the Python method pcbnew.LoadPlugins (already called when starting Pcbnew) - PyRun_SimpleString( cmd ); - } + PythonPluginsReloadBase(); } #endif diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 94c83f6d69..3402bbf91b 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -1159,24 +1159,19 @@ void PCB_EDIT_FRAME::OnFlipPcbView( wxCommandEvent& evt ) Refresh(); } + void PCB_EDIT_FRAME::PythonPluginsReload() { - // Reload plugin list: reload Python plugins if they are newer than + // Reload Python plugins if they are newer than // the already loaded, and load new plugins #if defined(KICAD_SCRIPTING) //Reload plugin list: reload Python plugins if they are newer than // the already loaded, and load new plugins - char cmd[1024]; - - snprintf( cmd, sizeof(cmd), - "pcbnew.LoadPlugins(\"%s\")", TO_UTF8( PyScriptingPath() ) ); - - PyLOCK lock; - - // ReRun the Python method pcbnew.LoadPlugins (already called when starting Pcbnew) - PyRun_SimpleString( cmd ); + PythonPluginsReloadBase(); #if defined(KICAD_SCRIPTING_ACTION_MENU) + // Action plugins can be modified, therefore the plugins menu + // must be updated: RebuildActionPluginMenus(); #endif #endif diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 8d8613a6b1..82bf71fe29 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -277,6 +277,25 @@ static bool scriptingSetup() #endif // KICAD_SCRIPTING +void PythonPluginsReloadBase() +{ +#if defined(KICAD_SCRIPTING) + //Reload plugin list: reload Python plugins if they are newer than + // the already loaded, and load new plugins + char cmd[1024]; + + snprintf( cmd, sizeof(cmd), + "pcbnew.LoadPlugins(\"%s\")", TO_UTF8( PyScriptingPath() ) ); + + PyLOCK lock; + + // ReRun the Python method pcbnew.LoadPlugins + // (already called when starting Pcbnew) + PyRun_SimpleString( cmd ); +#endif +} + + /// The global footprint library table. This is not dynamically allocated because /// in a multiple project environment we must keep its address constant (since it is /// the fallback table for multiple projects). diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 8f0f37006e..9253096897 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -108,5 +108,14 @@ enum MagneticPadOptionValues { capture_always }; +/** + * Helper function PythonPluginsReloadBase + * Reload Python plugins if they are newer than + * the already loaded, and load new plugins if any + * It calls the LoadPlugins(bundlepath) Python method + * see kicadplugins.i + */ +void PythonPluginsReloadBase(); + #endif // PCBNEW_H diff --git a/pcbnew/swig/pcbnew_action_plugins.cpp b/pcbnew/swig/pcbnew_action_plugins.cpp index 3e3c1e01d6..7118f7f283 100644 --- a/pcbnew/swig/pcbnew_action_plugins.cpp +++ b/pcbnew/swig/pcbnew_action_plugins.cpp @@ -197,12 +197,6 @@ void PCB_EDIT_FRAME::OnActionPlugin( wxCommandEvent& aEvent ) } -void PCB_EDIT_FRAME::OnActionPluginRefresh( wxCommandEvent& aEvent ) -{ - PythonPluginsReload(); -} - - void PCB_EDIT_FRAME::RebuildActionPluginMenus() { wxMenu* actionMenu = GetMenuBar()->FindItem( ID_TOOLBARH_PCB_ACTION_PLUGIN )->GetSubMenu();