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
This commit is contained in:
Jeff Young 2021-01-25 17:39:37 +00:00
parent dca7e44455
commit b576ccef61
2 changed files with 13 additions and 5 deletions

View File

@ -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 )

View File

@ -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;
}