Don't leave deleted items in a group.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15797

(cherry picked from commit 14d5a404b2)
This commit is contained in:
Jeff Young 2023-10-14 18:23:35 +01:00
parent 121394c0c0
commit e85eec2e6b
1 changed files with 3 additions and 1 deletions

View File

@ -38,6 +38,7 @@
#include <tools/board_editor_control.h>
#include <board.h>
#include <footprint.h>
#include <pcb_group.h>
#include <board_commit.h>
#include <footprint_edit_frame.h>
#include <wildcards_and_files_ext.h>
@ -764,7 +765,8 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr
pi->FootprintSave( libPath, fpCopy );
// Remove reference to the group before deleting
fpCopy->SetParentGroup( nullptr );
if( PCB_GROUP* parentGroup = fpCopy->GetParentGroup() )
parentGroup->RemoveItem( fpCopy );
delete fpCopy;
}