From 9d233b4cdbb516df6f9950b620104e92342b45e9 Mon Sep 17 00:00:00 2001 From: Maciej Sumiski Date: Tue, 9 Aug 2016 09:54:57 -0400 Subject: [PATCH] Pcbnew: fixed a crash when dragging a line was interrupted. (fixes lp:1606332) * Crash was caused by removing an element from m_activeTools list, causing other iterators to be invalidated when dragging line in GAL mode. --- common/tool/tool_manager.cpp | 12 ++++++------ include/tool/tool_manager.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 5e370a4112..447ab9906e 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -24,7 +24,7 @@ */ #include -#include +#include #include #include @@ -450,7 +450,7 @@ int TOOL_MANAGER::GetPriority( int aToolId ) const { int priority = 0; - for( std::deque::const_iterator it = m_activeTools.begin(), + for( std::list::const_iterator it = m_activeTools.begin(), itEnd = m_activeTools.end(); it != itEnd; ++it ) { if( *it == aToolId ) @@ -494,12 +494,12 @@ optional TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent ) { // iterate over all registered tools - for( std::deque::iterator it = m_activeTools.begin(); + for( std::list::iterator it = m_activeTools.begin(); it != m_activeTools.end(); /* iteration is done inside */) { - std::deque::iterator curIt = it; + std::list::iterator curIt = it; TOOL_STATE* st = m_toolIdIndex[*it]; - ++it; // it might be overwritten, if the tool is removed the m_activeTools deque + ++it; // it might be overwritten, if the tool is removed the m_activeTools list // the tool state handler is waiting for events (i.e. called Wait() method) if( st->pendingWait ) @@ -657,7 +657,7 @@ bool TOOL_MANAGER::finishTool( TOOL_STATE* aState, bool aDeactivate ) if( !aState->Pop() ) // if there are no other contexts saved on the stack { // find the tool and deactivate it - std::deque::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(), + std::list::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() ); if( tool != m_activeTools.end() ) diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 1036d605af..9b28f2355c 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -435,7 +435,7 @@ private: std::map m_toolIdIndex; /// Stack of the active tools - std::deque m_activeTools; + std::list m_activeTools; /// Instance of ACTION_MANAGER that handles TOOL_ACTIONs ACTION_MANAGER* m_actionMgr;