diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index c3a745543d..54772d12cf 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2018 CERN + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * @author Maciej Suminski * @@ -362,11 +363,20 @@ bool TOOL_MANAGER::runTool( TOOL_BASE* aTool ) static_cast( aTool )->resetTransitions(); // If the tool is already active, bring it to the top of the active tools stack - if( isActive( aTool ) ) + if( isActive( aTool ) && m_activeTools.size() > 1 ) { - m_activeTools.erase( std::find( m_activeTools.begin(), m_activeTools.end(), id ) ); - m_activeTools.push_front( id ); - return false; + auto it = std::find( m_activeTools.begin(), m_activeTools.end(), id ); + + if( it != m_activeTools.end() ) + { + if( it != m_activeTools.begin() ) + { + m_activeTools.erase( it ); + m_activeTools.push_front( id ); + } + + return false; + } } setActiveState( m_toolIdIndex[id] );