From a77e1027d6ce03ffd45410af86f00a28624d0bbb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 22 Aug 2025 12:53:43 -0700 Subject: [PATCH] Fix QA error. When updating the symbol, we clear the libpins, so remove it to avoid getting garbage while updating --- eeschema/sch_symbol.cpp | 7 ++++++- qa/tests/eeschema/test_sch_pin.cpp | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index beb75f2510..a4644449b5 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -254,6 +254,12 @@ void SCH_SYMBOL::SetLibSymbol( LIB_SYMBOL* aLibSymbol ) wxCHECK2( !aLibSymbol || aLibSymbol->IsRoot(), aLibSymbol = nullptr ); m_part.reset( aLibSymbol ); + + // We've just reset the library symbol, so the lib_pins, which were just + // pointers to the old symbol, need to be cleared. + for( auto& pin : m_pins ) + pin->SetLibPin( nullptr ); + UpdatePins(); } @@ -302,7 +308,6 @@ void SCH_SYMBOL::UpdatePins() if( !pin->GetAlt().IsEmpty() ) { altPinMap[ pin->GetNumber() ] = pin->GetAlt(); - auto altDefIt = pin->GetAlternates().find( pin->GetAlt() ); if( altDefIt != pin->GetAlternates().end() ) diff --git a/qa/tests/eeschema/test_sch_pin.cpp b/qa/tests/eeschema/test_sch_pin.cpp index 7525748b24..5811956bf7 100644 --- a/qa/tests/eeschema/test_sch_pin.cpp +++ b/qa/tests/eeschema/test_sch_pin.cpp @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE( AlternatePinRenameUpdates ) alt.m_Type = ELECTRICAL_PINTYPE::PT_INPUT; m_lib_pin->GetAlternates()[ wxS( "ALT1" ) ] = alt; - m_parent_symbol->UpdatePins(); + m_parent_symbol->SetLibSymbol( m_parent_part->Flatten().release() ); m_sch_pin = m_parent_symbol->GetPins()[0]; m_sch_pin->SetAlt( wxS( "ALT1" ) ); @@ -207,7 +207,6 @@ BOOST_AUTO_TEST_CASE( AlternatePinRenameUpdates ) m_lib_pin->GetAlternates()[ wxS( "ALT1_NEW" ) ] = altNew; m_parent_symbol->SetLibSymbol( m_parent_part->Flatten().release() ); - m_parent_symbol->UpdatePins(); SCH_PIN* updatedPin = m_parent_symbol->GetPins()[0];