Browse Source

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

pull/3/merge
Michael Steinberg 9 years ago
committed by Wayne Stambaugh
parent
commit
86496d3141
  1. 8
      common/tool/tool_manager.cpp
  2. 6
      include/tool/tool_manager.h
  3. 4
      pcbnew/pcb_base_edit_frame.cpp

8
common/tool/tool_manager.cpp

@ -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 )
{

6
include/tool/tool_manager.h

@ -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).

4
pcbnew/pcb_base_edit_frame.cpp

@ -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();

Loading…
Cancel
Save