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.
This commit is contained in:
Maciej Sumiski 2016-08-09 09:54:57 -04:00 committed by Wayne Stambaugh
parent 19c54933c1
commit 9d233b4cdb
2 changed files with 7 additions and 7 deletions

View File

@ -24,7 +24,7 @@
*/
#include <map>
#include <deque>
#include <list>
#include <stack>
#include <algorithm>
@ -450,7 +450,7 @@ int TOOL_MANAGER::GetPriority( int aToolId ) const
{
int priority = 0;
for( std::deque<int>::const_iterator it = m_activeTools.begin(),
for( std::list<TOOL_ID>::const_iterator it = m_activeTools.begin(),
itEnd = m_activeTools.end(); it != itEnd; ++it )
{
if( *it == aToolId )
@ -494,12 +494,12 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool,
void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
{
// iterate over all registered tools
for( std::deque<TOOL_ID>::iterator it = m_activeTools.begin();
for( std::list<TOOL_ID>::iterator it = m_activeTools.begin();
it != m_activeTools.end(); /* iteration is done inside */)
{
std::deque<TOOL_ID>::iterator curIt = it;
std::list<TOOL_ID>::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<TOOL_ID>::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(),
std::list<TOOL_ID>::iterator tool = std::find( m_activeTools.begin(), m_activeTools.end(),
aState->theTool->GetId() );
if( tool != m_activeTools.end() )

View File

@ -435,7 +435,7 @@ private:
std::map<TOOL_ID, TOOL_STATE*> m_toolIdIndex;
/// Stack of the active tools
std::deque<TOOL_ID> m_activeTools;
std::list<TOOL_ID> m_activeTools;
/// Instance of ACTION_MANAGER that handles TOOL_ACTIONs
ACTION_MANAGER* m_actionMgr;