From b2679b76483008f20c9318f7062267be1c5f0cdc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 14 Mar 2023 11:48:00 +0000 Subject: [PATCH] Swap pins for undo. Fixes https://gitlab.com/kicad/code/kicad/issues/14100 (cherry picked from commit c266913ec72092baf78e11a6b87be80617d3072e) --- eeschema/sch_symbol.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 1be87fdd80..28c01c374c 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1095,6 +1095,14 @@ void SCH_SYMBOL::SwapData( SCH_ITEM* aItem ) std::swap( m_lib_id, symbol->m_lib_id ); + m_pins.swap( symbol->m_pins ); // std::vector's swap() + + for( std::unique_ptr& pin : symbol->m_pins ) + pin->SetParent( symbol ); + + for( std::unique_ptr& pin : m_pins ) + pin->SetParent( this ); + LIB_SYMBOL* libSymbol = symbol->m_part.release(); symbol->m_part = std::move( m_part ); symbol->UpdatePins();