Browse Source

Fix a wxRecursionGuard crash when library symbol is missing.

The various wxCHECKs in the SCH_PIN object where being raised inside
the SCH_SYMBOL object which would also raise it's own wxCHECK that
would cause a recursion guard failure and segfault.  The offending
wxCHECKs were replaced with null pointer checks.  Missing library
symbol links will be shown with the missing library symbol.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17146
8.0
Wayne Stambaugh 10 months ago
parent
commit
cf71e5707e
  1. 23
      eeschema/sch_pin.cpp
  2. 11
      eeschema/sch_symbol.cpp

23
eeschema/sch_pin.cpp

@ -126,7 +126,8 @@ wxString SCH_PIN::GetShownNumber() const
ELECTRICAL_PINTYPE SCH_PIN::GetType() const
{
wxCHECK( m_libPin, ELECTRICAL_PINTYPE::PT_NC );
if( !m_libPin )
return ELECTRICAL_PINTYPE::PT_NC;
if( !m_alt.IsEmpty() )
return m_libPin->GetAlt( m_alt ).m_Type;
@ -137,7 +138,8 @@ ELECTRICAL_PINTYPE SCH_PIN::GetType() const
GRAPHIC_PINSHAPE SCH_PIN::GetShape() const
{
wxCHECK( m_libPin, GRAPHIC_PINSHAPE::LINE );
if( !m_libPin )
return GRAPHIC_PINSHAPE::LINE;
if( !m_alt.IsEmpty() )
return m_libPin->GetAlt( m_alt ).m_Shape;
@ -148,7 +150,8 @@ GRAPHIC_PINSHAPE SCH_PIN::GetShape() const
PIN_ORIENTATION SCH_PIN::GetOrientation() const
{
wxCHECK( m_libPin, PIN_ORIENTATION::PIN_RIGHT );
if( !m_libPin )
return PIN_ORIENTATION::PIN_RIGHT;
return m_libPin->GetOrientation();
}
@ -156,7 +159,8 @@ PIN_ORIENTATION SCH_PIN::GetOrientation() const
int SCH_PIN::GetLength() const
{
wxCHECK( m_libPin, 0 );
if( !m_libPin )
return 0;
return m_libPin->GetLength();
}
@ -301,7 +305,8 @@ bool SCH_PIN::IsStacked( const SCH_PIN* aPin ) const
bool SCH_PIN::IsGlobalPower() const
{
wxCHECK( m_libPin, false );
if( !m_libPin )
return false;
return m_libPin->IsGlobalPower();
}
@ -425,8 +430,6 @@ const BOX2I SCH_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNa
if( m_libPin )
r = m_libPin->GetBoundingBox( aIncludeInvisiblePins, aIncludeNameAndNumber,
aIncludeElectricalType );
else
wxFAIL;
r.RevertYAxis();
@ -491,7 +494,8 @@ bool SCH_PIN::HasConnectivityChanges( const SCH_ITEM* aItem,
bool SCH_PIN::ConnectionPropagatesTo( const EDA_ITEM* aItem ) const
{
wxCHECK( m_libPin, false );
if( !m_libPin )
return false;
// Reciprocal checking is done in CONNECTION_GRAPH anyway
return !( m_libPin->GetType() == ELECTRICAL_PINTYPE::PT_NC );
@ -511,6 +515,9 @@ bool SCH_PIN::operator==( const SCH_ITEM& aOther ) const
if( m_position != other.m_position )
return false;
if( !m_libPin )
return false;
return m_libPin == other.m_libPin;
}

11
eeschema/sch_symbol.cpp

@ -2177,12 +2177,12 @@ bool SCH_SYMBOL::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListB
}
VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition( const LIB_PIN* Pin ) const
VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition( const LIB_PIN* aPin ) const
{
wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, VECTOR2I( 0, 0 ),
wxT( "Cannot get physical position of pin." ) );
if( ( aPin == nullptr ) || ( aPin->Type() != LIB_PIN_T ) )
return VECTOR2I( 0, 0 );
return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_pos;
return m_transform.TransformCoordinate( aPin->GetPosition() ) + m_pos;
}
@ -2699,7 +2699,8 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const
bool SCH_SYMBOL::IsPower() const
{
wxCHECK( m_part, false );
if( !m_part )
return false;
return m_part->IsPower();
}

Loading…
Cancel
Save