Clean up items which weren't pasted from clipboard.

Fixes https://gitlab.com/kicad/code/kicad/issues/14335
This commit is contained in:
Jeff Young 2023-03-17 23:16:48 +00:00
parent 607622e8f8
commit ad5d3d4eba
1 changed files with 15 additions and 0 deletions

View File

@ -944,6 +944,21 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
} }
} }
clipBoard->Visit(
[&]( EDA_ITEM* item, void* testData )
{
// Anything still on the clipboard didn't get copied and needs to be
// removed from the pasted groups.
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
PCB_GROUP* parentGroup = boardItem->GetParentGroup();
if( parentGroup )
parentGroup->RemoveItem( boardItem );
return INSPECT_RESULT::CONTINUE;
},
nullptr, GENERAL_COLLECTOR::AllBoardItems );
delete clipBoard; delete clipBoard;
pruneItemLayers( pastedItems ); pruneItemLayers( pastedItems );