Remove & then re-add undo items to parent group.

Removing the item from the board will also remove it
from any parent group, which then wasn't getting
restored.  This makes it more clear that we need to
remove and then re-add.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18017
This commit is contained in:
Jeff Young 2024-05-17 19:33:43 +01:00
parent 7f03666f96
commit ea72beb2f7
1 changed files with 9 additions and 0 deletions

View File

@ -433,6 +433,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) eda_item; BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
BOARD_ITEM_CONTAINER* parent = GetBoard(); BOARD_ITEM_CONTAINER* parent = GetBoard();
PCB_GROUP* parentGroup = item->GetParentGroup();
if( item->GetParentFootprint() ) if( item->GetParentFootprint() )
{ {
@ -445,6 +446,10 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii ); BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
view->Remove( item ); view->Remove( item );
if( parentGroup )
parentGroup->RemoveItem( item );
parent->Remove( item ); parent->Remove( item );
item->SwapItemData( image ); item->SwapItemData( image );
@ -463,6 +468,10 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
view->Add( item ); view->Add( item );
view->Hide( item, false ); view->Hide( item, false );
parent->Add( item ); parent->Add( item );
if( parentGroup )
parentGroup->AddItem( item );
update_item_change_state( item, ITEM_CHANGE_TYPE::CHANGED ); update_item_change_state( item, ITEM_CHANGE_TYPE::CHANGED );
break; break;
} }