From 985e590e6f55814a12c435a83e5ec652a94ff2e5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 31 Dec 2023 21:36:33 +0000 Subject: [PATCH] PCB_FIELDs don't belong in the view. They're handled by their parent FOOTPRINTs. Also makes sure footprint children get their parents updated on a swap. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16412 --- pcbnew/footprint.cpp | 16 +++++++++++++++- pcbnew/netlist_reader/board_netlist_updater.cpp | 4 ---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 8c5a30994b..5a8809e30e 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -2963,7 +2963,21 @@ void FOOTPRINT::swapData( BOARD_ITEM* aImage ) { wxASSERT( aImage->Type() == PCB_FOOTPRINT_T ); - std::swap( *this, *static_cast( aImage ) ); + FOOTPRINT* image = static_cast( aImage ); + + std::swap( *this, *image ); + + RunOnChildren( + [&]( BOARD_ITEM* child ) + { + child->SetParent( this ); + } ); + + image->RunOnChildren( + [&]( BOARD_ITEM* child ) + { + child->SetParent( image ); + } ); } diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index a671e3f2af..8d107cade6 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -436,11 +436,7 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint, newField->Rotate( aPcbFootprint->GetPosition(), aPcbFootprint->GetOrientation() ); if( m_frame ) - { newField->StyleFromSettings( m_frame->GetDesignSettings() ); - KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView(); - view->Add( newField ); - } } }