Fix group undo/redo bugs.

1) Don't remove items from group when the group is being deleted as
well.  We need those pointers for undo/redo.
2) Flip the GROUP/UNGROUP undo status when undoing/redoing group and
ungroup actions.
3) Remove PCB_GROUP_T from the rebuild-netlists section.  Nothing
about an item's group/ungrouped status changes its netlisting.
4) Add PCB_PAD_T to the rebuild-netlists section.  It can probably
only happen in the footprint editor where we don't care about
netlisting, but it's conceptually more correct and who knows what
might change in the future....

Fixes https://gitlab.com/kicad/code/kicad/issues/7540
This commit is contained in:
Jeff Young 2021-02-15 13:49:40 +00:00
parent 443b85739c
commit b08862e445
4 changed files with 20 additions and 9 deletions

View File

@ -738,8 +738,12 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
}
if( aBoardItem->GetParentGroup() )
aBoardItem->GetParentGroup()->RemoveItem( aBoardItem );
aBoardItem->SetFlags( STRUCT_DELETED );
PCB_GROUP* parentGroup = aBoardItem->GetParentGroup();
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
parentGroup->RemoveItem( aBoardItem );
m_connectivity->Remove( aBoardItem );

View File

@ -182,6 +182,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case CHT_REMOVE:
{
PCB_GROUP* parentGroup = boardItem->GetParentGroup();
if( !m_isFootprintEditor && aCreateUndoEntry )
undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
@ -212,8 +214,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
break;
}
if( boardItem->GetParentGroup() )
boardItem->GetParentGroup()->RemoveItem( boardItem );
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
parentGroup->RemoveItem( boardItem );
view->Remove( boardItem );

View File

@ -580,8 +580,12 @@ void FOOTPRINT::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode )
}
}
if( aBoardItem->GetParentGroup() )
aBoardItem->GetParentGroup()->RemoveItem( aBoardItem );
aBoardItem->SetFlags( STRUCT_DELETED );
PCB_GROUP* parentGroup = aBoardItem->GetParentGroup();
if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
parentGroup->RemoveItem( aBoardItem );
if( aBoardItem->Type() != PCB_FP_TEXT_T )
m_hullDirty = true;

View File

@ -428,7 +428,6 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
switch( eda_item->Type() )
{
case PCB_FOOTPRINT_T:
case PCB_GROUP_T:
deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
KI_FALLTHROUGH;
@ -436,6 +435,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
case PCB_TRACE_T:
case PCB_ARC_T:
case PCB_VIA_T:
case PCB_PAD_T:
reBuild_ratsnest = true;
break;
@ -491,10 +491,13 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
break;
case UNDO_REDO::GROUP:
aList->SetPickedItemStatus( UNDO_REDO::UNGROUP, ii );
static_cast<BOARD_ITEM*>( eda_item )->SetParentGroup( nullptr );
break;
case UNDO_REDO::UNGROUP:
aList->SetPickedItemStatus( UNDO_REDO::GROUP, ii );
if( group )
group->AddItem( static_cast<BOARD_ITEM*>( eda_item ) );
@ -549,8 +552,6 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
}
void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
{
if( aItemCount == 0 )