From 80462cf55949ed3ae23158bb9007fc478f6bd741 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 14 Jun 2023 23:33:41 +0100 Subject: [PATCH] Remove temp items from its group before deleting them The 1st level items being copied don't have their group information copied, and we assert that it has been removed from the group on deleting it, so we just reset the group membership to prevent the assert. Fixes sentry KICAD-22S (Cherry-picked from 753cc6679b8c38c7b446320c791ac0f80ab1cf5f) --- pcbnew/kicad_clipboard.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 4aee25c4d7..450b790e7c 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -96,6 +96,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri Format( static_cast( &newFootprint ) ); newFootprint.SetParent( nullptr ); + newFootprint.SetParentGroup( nullptr ); } else if( isFootprintEditor ) { @@ -128,6 +129,10 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri if( PAD* pad = dyn_cast( clone ) ) pad->SetNetCode( 0 ); + // Don't copy group membership information for the 1st level objects being copied + // since the group they belong to isn't being copied. + clone->SetParentGroup( nullptr ); + // Add the pad to the new footprint before moving to ensure the local coords are // correct partialFootprint.Add( clone ); @@ -163,7 +168,10 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri // Now delete items, duplicated but not added: for( BOARD_ITEM* skp_item : skipped_items ) + { + skp_item->SetParentGroup( nullptr ); delete skp_item; + } } // Set the new relative internal local coordinates of copied items @@ -283,6 +291,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri } ); } + copy->SetParentGroup( nullptr ); delete copy; } }