Commit af976b2d authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Automatic unregistration of tool actions during ACTION_MANAGER destruction.

parent c21ae6ef
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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
+6 −0
Original line number Diff line number Diff line
@@ -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
+1 −6
Original line number Diff line number Diff line
@@ -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;
}