From d261fa3792d2fe179066c9d1e3a5f2691c771c35 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 Feb 2021 11:57:48 +0000 Subject: [PATCH] Make sure items are removed from groups when deleted. Fixes https://gitlab.com/kicad/code/kicad/issues/7387 --- pcbnew/board.cpp | 7 ++++++- pcbnew/board_commit.cpp | 9 +++++++-- pcbnew/footprint.cpp | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index e577838e67..293a15079e 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -738,6 +738,9 @@ 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 ); + m_connectivity->Remove( aBoardItem ); if( aRemoveMode != REMOVE_MODE::BULK ) @@ -2011,7 +2014,9 @@ wxString BOARD::GroupsSanityCheck( bool repair ) { if( repair ) { - while( GroupsSanityCheckInternal( repair ) != wxEmptyString ); + while( GroupsSanityCheckInternal( repair ) != wxEmptyString ) + {}; + return wxEmptyString; } return GroupsSanityCheckInternal( repair ); diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index f4f332eadc..5d77bca09d 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -193,12 +193,14 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a switch( boardItem->Type() ) { - // Module items + // Footprint items case PCB_PAD_T: case PCB_FP_SHAPE_T: case PCB_FP_TEXT_T: case PCB_FP_ZONE_T: - // This level can only handle footprint children when editing footprints + // This level can only handle footprint children in the footprint editor as + // only in that case has the entire footprint (and all its children) already + // been saved for undo. wxASSERT( m_isFootprintEditor ); if( boardItem->Type() == PCB_FP_TEXT_T ) @@ -210,6 +212,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a break; } + if( boardItem->GetParentGroup() ) + boardItem->GetParentGroup()->RemoveItem( boardItem ); + view->Remove( boardItem ); if( !( changeFlags & CHT_DONE ) ) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 22e8fd0123..74fc61d851 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -562,6 +562,9 @@ void FOOTPRINT::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode ) wxFAIL_MSG( msg ); } } + + if( aBoardItem->GetParentGroup() ) + aBoardItem->GetParentGroup()->RemoveItem( aBoardItem ); }