From b576ccef610449e78ec008706204e625e89549e2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 25 Jan 2021 17:39:37 +0000 Subject: [PATCH] Don't double-up tools on tool stack. Also make sure move tool gets cancelled by other tools being activated. Fixes https://gitlab.com/kicad/code/kicad/issues/7259 --- common/tool/tools_holder.cpp | 10 +++++++++- eeschema/tools/sch_move_tool.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/tool/tools_holder.cpp b/common/tool/tools_holder.cpp index d37aaaa7a9..1d2915a01c 100644 --- a/common/tool/tools_holder.cpp +++ b/common/tool/tools_holder.cpp @@ -43,7 +43,15 @@ TOOLS_HOLDER::TOOLS_HOLDER() : // TODO: Implement an RAII mechanism for the stack PushTool/PopTool pairs void TOOLS_HOLDER::PushTool( const std::string& actionName ) { - m_toolStack.push_back( actionName ); + if( m_toolStack.size() && m_toolStack.back() == actionName ) + { + // Tool already on the stack; we don't need to push again. (Happens when one tool is + // popped due to the activation of the same tool that is underneath it on the stack.) + } + else + { + m_toolStack.push_back( actionName ); + } // Human cognitive stacking is very shallow; deeper tool stacks just get annoying if( m_toolStack.size() > 3 ) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 8685044b0a..feb5c02ae0 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -379,13 +379,13 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) //------------------------------------------------------------------------ // Handle cancel // - else if( evt->IsCancelInteractive() ) + else if( evt->IsCancelInteractive() || evt->IsActivate() ) { - if( m_moveInProgress ) - { + if( m_moveInProgress && evt->IsCancelInteractive() ) evt->SetPassEvent( false ); + + if( m_moveInProgress ) restore_state = true; - } break; }