Rework on plugins reload code: avoid duplicate code.
This commit is contained in:
parent
6c5808fd18
commit
7bda89cdf6
|
@ -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
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <kiface_i.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <pcbnew.h>
|
||||
#include <3d_viewer/eda_3d_viewer.h>
|
||||
#include <msgpanel.h>
|
||||
#include <macros.h>
|
||||
|
@ -721,7 +722,6 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
|
|||
}
|
||||
|
||||
#if defined(KICAD_SCRIPTING)
|
||||
#include <python_scripting.h>
|
||||
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue