From 981aafd5d9ff80d2fa3ec278576d3d8c60aecda8 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 2 Oct 2022 13:36:33 -0700 Subject: [PATCH] Allow non-named tool in Remove() The tool command string was optional and not set when calling Remove() through the Cut action. Referencing the value causes unhandled assertions. We don't actually need the value because we don't pop anything without a match. The empty string will not match Fixes https://gitlab.com/kicad/code/kicad/issues/12562 --- pcbnew/tools/edit_tool.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 092b86c5cf..ad50306699 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1799,8 +1799,13 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) return 0; } - std::string tool = aEvent.GetCommandStr().value(); - editFrame->PushTool( tool ); + std::string tool{}; + + if( aEvent.GetCommandStr() ) + { + tool = aEvent.GetCommandStr().value(); + editFrame->PushTool( tool ); + } std::vector lockedItems; Activate(); @@ -2494,7 +2499,7 @@ int EDIT_TOOL::cutToClipboard( const TOOL_EVENT& aEvent ) // N.B. Setting the CUT flag prevents lock filtering as we only want to delete the items // that were copied to the clipboard, no more, no fewer. Filtering for locked item, if // any will be done in the copyToClipboard() routine - TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), TOOL_ACTION_SCOPE::AS_GLOBAL ); + TOOL_EVENT evt( aEvent.Category(), aEvent.Action(), "Cut", TOOL_ACTION_SCOPE::AS_GLOBAL ); evt.SetParameter( PCB_ACTIONS::REMOVE_FLAGS::CUT ); Remove( evt ); }