Fix for crash due to pcbnew_action_plugin object tracking

pcbnew_action_plug tracks items that were modified within a plugin. In the case of
deletion, the old object is no longer valid. This commit turns off the call to delete
if a plugin is active.
This commit is contained in:
Miles McCoo 2018-03-06 09:28:57 +01:00 committed by Maciej Suminski
parent 935a5cada8
commit 9d98fe1b80
6 changed files with 44 additions and 2 deletions

View File

@ -44,6 +44,9 @@ void ACTION_PLUGIN::register_action()
std::vector<ACTION_PLUGIN*> ACTION_PLUGINS::m_actionsList;
bool ACTION_PLUGINS::m_actionRunning = false;
ACTION_PLUGIN* ACTION_PLUGINS::GetAction( int aIndex )
{
return m_actionsList[aIndex];
@ -147,3 +150,15 @@ bool ACTION_PLUGINS::deregister_object( void* aObject )
return false;
}
bool ACTION_PLUGINS::IsActionRunning()
{
return ACTION_PLUGINS::m_actionRunning;
}
void ACTION_PLUGINS::SetActionRunning( bool aRunning )
{
ACTION_PLUGINS::m_actionRunning = aRunning;
}

View File

@ -101,7 +101,7 @@ private:
* ACTION_PLUGIN system wide static list
*/
static std::vector<ACTION_PLUGIN*> m_actionsList;
static bool m_actionRunning;
public:
/**
* Function register_action
@ -168,6 +168,18 @@ public:
* @return the number of actions available into the system
*/
static int GetActionsCount();
/**
* Function IsActionRunning
* @return Is an action running right now
*/
static bool IsActionRunning();
/**
* Function SetActionRunning
* @param aRunning sets whether an action is running now.
*/
static void SetActionRunning( bool aRunning );
};
#endif /* PCBNEW_ACTION_PLUGINS_H */

View File

@ -32,7 +32,8 @@
Remove(self, BOARD_ITEM)
"""
self.RemoveNative(item)
item.thisown=1
if (not IsActionRunning()):
item.thisown=1
def Delete(self,item):
"""

View File

@ -230,7 +230,9 @@ void PCB_EDIT_FRAME::OnActionPlugin( wxCommandEvent& aEvent )
itemsList.ClearItemsList();
// Execute plugin himself...
ACTION_PLUGINS::SetActionRunning( true );
actionPlugin->Run();
ACTION_PLUGINS::SetActionRunning( false );
currentPcb->m_Status_Pcb = 0;

View File

@ -40,6 +40,7 @@
#include <macros.h>
#include <stdlib.h>
#include <pcb_draw_panel_gal.h>
#include <action_plugin.h>
static PCB_EDIT_FRAME* s_PcbEditFrame = NULL;
@ -135,3 +136,9 @@ void UpdateUserInterface()
if( s_PcbEditFrame )
s_PcbEditFrame->UpdateUserInterface();
}
bool IsActionRunning()
{
return ACTION_PLUGINS::IsActionRunning();
}

View File

@ -69,4 +69,9 @@ void WindowZoom( int xl, int yl, int width, int height );
*/
void UpdateUserInterface();
/**
* Are we currently in an action plugin?
*/
bool IsActionRunning();
#endif // __PCBNEW_SCRIPTING_HELPERS_H