From 2aa8a3724f3efa81513f41a933dcb594cf251494 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 5 Feb 2021 10:16:45 -0800 Subject: [PATCH] Don't continue until the move tool completes Starting a new action (to add junctions) will break the move tool loop and cancel placement. We need to wait until the tool completes before choosing where to place the junctions Fixes https://gitlab.com/kicad/code/kicad/issues/7421 --- eeschema/tools/sch_edit_tool.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 2d8dfb248f..b2f9661735 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -959,15 +959,25 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent ) m_selectionTool->AddItemToSel( newItem ); if( performDrag ) + { m_toolMgr->RunAction( EE_ACTIONS::move, true ); + SCH_MOVE_TOOL* moveTool = m_toolMgr->GetTool(); + + // We cannot proceed until the move tool has ended (by placement or cancel) otherwise, + // we risk breaking out of the tool by activating another + while( moveTool->IsToolActive() ) + Wait(); + } + newItem->ClearFlags(); if( newItem->IsConnectable() ) { - auto selection = m_selectionTool->GetSelection(); + EE_SELECTION new_sel = m_selectionTool->GetSelection(); + new_sel.Add( newItem ); - m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection ); + m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &new_sel ); m_frame->SchematicCleanUp(); m_frame->TestDanglingEnds(); }