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];