From 7bc0f8731ff7406d1d493dd68745e3fadd7ea6f6 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 28 Jun 2023 21:56:46 +0100 Subject: [PATCH] Remove group reference when exporting individual footprints (Cherry-picked from d923b871d703e07ab7d8934800480b7f5c3b502c) --- pcbnew/footprint_libraries_utils.cpp | 3 +++ pcbnew/plugins/kicad/pcb_plugin.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 1c968fc8df..04c4459538 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -763,6 +763,9 @@ void PCB_EDIT_FRAME::ExportFootprintsToLibrary( bool aStoreInNewLib, const wxStr resetReference( fpCopy ); pi->FootprintSave( libPath, fpCopy ); + // Remove reference to the group before deleting + fpCopy->SetParentGroup( nullptr ); + delete fpCopy; } } diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 004a0e76f3..6755b62f8f 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -2675,8 +2675,9 @@ void PCB_PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* a footprint->Flip( footprint->GetPosition(), false ); } - // Detach it from the board + // Detach it from the board and its group footprint->SetParent( nullptr ); + footprint->SetParentGroup( nullptr ); wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath ); footprints.insert( footprintName,