Prevent invalid decrement in tool manager
Iterating over the tool stack, we potentially remove the current iterator. If this removal happens at the beginning of the toolstack, we cannot decrement the iterator to a position before the stack without creating an invalid state.
This commit is contained in:
parent
94e2690fed
commit
1770a1ea21
|
@ -648,16 +648,22 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
|
||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal %s", aEvent.Format() );
|
||||
|
||||
auto it = m_activeTools.begin();
|
||||
|
||||
// iterate over active tool stack
|
||||
for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
|
||||
while( it != m_activeTools.end() )
|
||||
{
|
||||
TOOL_STATE* st = m_toolIdIndex[*it];
|
||||
bool increment = true;
|
||||
|
||||
// forward context menu events to the tool that created the menu
|
||||
if( aEvent.IsChoiceMenu() )
|
||||
{
|
||||
if( *it != m_menuOwner )
|
||||
{
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// the tool state handler is waiting for events (i.e. called Wait() method)
|
||||
|
@ -685,7 +691,7 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
if( end )
|
||||
{
|
||||
it = finishTool( st );
|
||||
--it;
|
||||
increment = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,6 +707,9 @@ bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( increment )
|
||||
++it;
|
||||
}
|
||||
|
||||
for( auto& state : m_toolState )
|
||||
|
|
Loading…
Reference in New Issue