Automatic unregistration of tool actions during ACTION_MANAGER destruction.

This commit is contained in:
Maciej Suminski 2013-11-28 15:24:19 +01:00
parent c21ae6efca
commit af976b2d36
3 changed files with 14 additions and 6 deletions

View File

@ -34,6 +34,13 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
}
ACTION_MANAGER::~ACTION_MANAGER()
{
while( !m_actionIdIndex.empty() )
UnregisterAction( m_actionIdIndex.begin()->second );
}
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
{
assert( aAction->GetId() == -1 ); // Check if the TOOL_ACTION was not registered before

View File

@ -47,6 +47,12 @@ public:
*/
ACTION_MANAGER( TOOL_MANAGER* aToolManager );
/**
* Destructor.
* Unregisters every registered action.
*/
~ACTION_MANAGER();
/**
* Function RegisterAction()
* Adds a tool action to the manager and sets it up. After that is is possible to invoke

View File

@ -61,13 +61,8 @@ void PCB_EDIT_FRAME::setupTools()
void PCB_EDIT_FRAME::destroyTools()
{
m_toolManager->UnregisterAction( &COMMON_ACTIONS::moveActivate );
m_toolManager->UnregisterAction( &COMMON_ACTIONS::selectionActivate );
m_toolManager->UnregisterAction( &COMMON_ACTIONS::rotate );
m_toolManager->UnregisterAction( &COMMON_ACTIONS::flip );
delete m_toolDispatcher;
delete m_toolManager;
delete m_toolDispatcher;
}