From 1f627a3a75725eb0ad3898318ad1dcb6a5eedff8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 21 Dec 2023 22:34:21 +0000 Subject: [PATCH] Fix two unrelated bugs in ungroup. 1) Don't double-remove the members from the group. 2) Don't auto-recurse BOARD_COMMIT::Stage for non-modify changes. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16419 --- pcbnew/board_commit.cpp | 15 +++++++++------ pcbnew/tools/group_tool.cpp | 1 - 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 361a6bd92e..1a4dfadc0b 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -78,13 +78,16 @@ COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCRE // Many operations (move, rotate, etc.) are applied directly to a group's children, so they // must be staged as well. - if( PCB_GROUP* group = dynamic_cast( aItem ) ) + if( aChangeType == CHT_MODIFY ) { - group->RunOnChildren( - [&]( BOARD_ITEM* child ) - { - Stage( child, aChangeType ); - } ); + if( PCB_GROUP* group = dynamic_cast( aItem ) ) + { + group->RunOnChildren( + [&]( BOARD_ITEM* child ) + { + Stage( child, aChangeType ); + } ); + } } return COMMIT::Stage( aItem, aChangeType ); diff --git a/pcbnew/tools/group_tool.cpp b/pcbnew/tools/group_tool.cpp index 862d039950..9481124994 100644 --- a/pcbnew/tools/group_tool.cpp +++ b/pcbnew/tools/group_tool.cpp @@ -311,7 +311,6 @@ int GROUP_TOOL::Ungroup( const TOOL_EVENT& aEvent ) toSelect.push_back( member ); } - group->GetItems().clear(); group->SetSelected(); commit.Remove( group ); }