diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 04c4459538..05160e883d 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -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; }