Pcbnew: fix dangling board reference crash in GAL. (fixes lp:1584489)

This commit is contained in:
Michael Steinberg 2016-08-05 13:45:14 -04:00 committed by Wayne Stambaugh
parent 498c8ce61d
commit 86496d3141
3 changed files with 16 additions and 2 deletions

View File

@ -427,11 +427,15 @@ TOOL_BASE* TOOL_MANAGER::FindTool( const std::string& aName ) const
return NULL;
}
void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
void TOOL_MANAGER::DeactivateTool()
{
TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, "" ); // deactivate the active tool
ProcessEvent( evt );
}
void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
{
DeactivateTool();
for( TOOL_BASE* tool : m_toolState | boost::adaptors::map_keys )
{

View File

@ -186,6 +186,12 @@ public:
return NULL;
}
/**
* Function DeactivateTool()
* Deactivates the currently active tool.
*/
void DeactivateTool();
/**
* Function ResetTools()
* Resets all tools (i.e. calls their Reset() method).

View File

@ -68,6 +68,10 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
{
bool new_board = ( aBoard != m_Pcb );
// The active tool might store a reference to the BOARD that is about to be deleted.
if( m_toolManager )
m_toolManager->DeactivateTool();
// It has to be done before the previous board is destroyed by SetBoard()
if( new_board )
GetGalCanvas()->GetView()->Clear();