From ee05b67599e6d6efae77907d3d382e87f11a2ece Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 12 Dec 2022 12:58:53 -0800 Subject: [PATCH] Fix crash when moving empty selection Need to pop the move tool when exiting, even at the beginning Fixes https://gitlab.com/kicad/code/kicad/issues/13114 --- pcbnew/tools/edit_tool.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 3a76076af6..3994b0dc93 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -738,6 +738,9 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference, bool aRe KIGFX::VIEW_CONTROLS* controls = getViewControls(); VECTOR2I originalCursorPos = controls->GetCursorPosition(); + std::string tool = aEvent.GetCommandStr().get(); + editFrame->PushTool( tool ); + // Be sure that there is at least one item that we can modify. If nothing was selected before, // try looking for the stuff under mouse cursor (i.e. KiCad old-style hover selection) PCB_SELECTION& selection = m_selectionTool->RequestSelection( @@ -751,7 +754,10 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference, bool aRe frame()->Settings().m_AllowFreePads && !m_isFootprintEditor ); if( m_dragging || selection.Empty() ) + { + editFrame->PopTool( tool ); return 0; + } LSET item_layers = selection.GetSelectionLayers(); bool is_hover = selection.IsHover(); // N.B. This must be saved before the second call @@ -777,10 +783,10 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference, bool aRe } if( selection.Empty() ) + { + editFrame->PopTool( tool ); return 0; - - std::string tool = aEvent.GetCommandStr().get(); - editFrame->PushTool( tool ); + } Activate(); // Must be done after Activate() so that it gets set into the correct context