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 753cc6679b)
This commit is contained in:
Ian McInerney 2023-06-14 23:33:41 +01:00
parent e5df16ba2b
commit 80462cf559
1 changed files with 9 additions and 0 deletions

View File

@ -96,6 +96,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
Format( static_cast<BOARD_ITEM*>( &newFootprint ) ); Format( static_cast<BOARD_ITEM*>( &newFootprint ) );
newFootprint.SetParent( nullptr ); newFootprint.SetParent( nullptr );
newFootprint.SetParentGroup( nullptr );
} }
else if( isFootprintEditor ) else if( isFootprintEditor )
{ {
@ -128,6 +129,10 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
if( PAD* pad = dyn_cast<PAD*>( clone ) ) if( PAD* pad = dyn_cast<PAD*>( clone ) )
pad->SetNetCode( 0 ); 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 // Add the pad to the new footprint before moving to ensure the local coords are
// correct // correct
partialFootprint.Add( clone ); partialFootprint.Add( clone );
@ -163,7 +168,10 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
// Now delete items, duplicated but not added: // Now delete items, duplicated but not added:
for( BOARD_ITEM* skp_item : skipped_items ) for( BOARD_ITEM* skp_item : skipped_items )
{
skp_item->SetParentGroup( nullptr );
delete skp_item; delete skp_item;
}
} }
// Set the new relative internal local coordinates of copied items // 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; delete copy;
} }
} }