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

This commit is contained in:
Michael Steinberg 2016-08-05 08:49:12 -04:00 committed by Wayne Stambaugh
parent bcdcaa724d
commit 5f98fc0591
3 changed files with 16 additions and 2 deletions

View File

@ -428,11 +428,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();
BOOST_FOREACH( TOOL_BASE* tool, m_toolState | boost::adaptors::map_keys )
{

View File

@ -185,6 +185,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();