Keep local number up-to-date so we don't have to look at libPin's.

The libPin, in particuar, may have been freed.

Fixes https://gitlab.com/kicad/code/kicad/issues/5399
This commit is contained in:
Jeff Young 2020-08-31 20:09:07 +01:00
parent cd55185904
commit 1ea08f27f8
2 changed files with 9 additions and 11 deletions

View File

@ -27,9 +27,11 @@
SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) : SCH_PIN::SCH_PIN( LIB_PIN* aLibPin, SCH_COMPONENT* aParentComponent ) :
SCH_ITEM( aParentComponent, SCH_PIN_T ), SCH_ITEM( aParentComponent, SCH_PIN_T )
m_libPin( aLibPin )
{ {
m_alt = wxEmptyString;
m_number = aLibPin->GetNumber();
m_libPin = aLibPin;
SetPosition( aLibPin->GetPosition() ); SetPosition( aLibPin->GetPosition() );
m_isDangling = true; m_isDangling = true;
} }
@ -39,6 +41,7 @@ SCH_PIN::SCH_PIN( const SCH_PIN& aPin ) :
SCH_ITEM( aPin ) SCH_ITEM( aPin )
{ {
m_alt = aPin.m_alt; m_alt = aPin.m_alt;
m_number = aPin.m_number;
m_libPin = aPin.m_libPin; m_libPin = aPin.m_libPin;
m_position = aPin.m_position; m_position = aPin.m_position;
m_isDangling = aPin.m_isDangling; m_isDangling = aPin.m_isDangling;
@ -50,6 +53,7 @@ SCH_PIN& SCH_PIN::operator=( const SCH_PIN& aPin )
SCH_ITEM::operator=( aPin ); SCH_ITEM::operator=( aPin );
m_alt = aPin.m_alt; m_alt = aPin.m_alt;
m_number = aPin.m_number;
m_libPin = aPin.m_libPin; m_libPin = aPin.m_libPin;
m_position = aPin.m_position; m_position = aPin.m_position;
m_isDangling = aPin.m_isDangling; m_isDangling = aPin.m_isDangling;
@ -210,7 +214,7 @@ void SCH_PIN::ClearDefaultNetName( const SCH_SHEET_PATH* aPath )
} }
wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH aPath ) wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath )
{ {
if( m_libPin->IsPowerConnection() ) if( m_libPin->IsPowerConnection() )
return m_libPin->GetName(); return m_libPin->GetName();

View File

@ -67,7 +67,7 @@ public:
LIB_PIN* GetLibPin() const { return m_libPin; } LIB_PIN* GetLibPin() const { return m_libPin; }
void ClearDefaultNetName( const SCH_SHEET_PATH* aPath ); void ClearDefaultNetName( const SCH_SHEET_PATH* aPath );
wxString GetDefaultNetName( const SCH_SHEET_PATH aPath ); wxString GetDefaultNetName( const SCH_SHEET_PATH& aPath );
wxString GetAlt() const { return m_alt; } wxString GetAlt() const { return m_alt; }
void SetAlt( const wxString& aAlt ) { m_alt = aAlt; } void SetAlt( const wxString& aAlt ) { m_alt = aAlt; }
@ -109,13 +109,7 @@ public:
wxString GetName() const; wxString GetName() const;
wxString GetNumber() const wxString GetNumber() const { return m_number; }
{
if( m_libPin )
return m_libPin->GetNumber();
else
return m_number;
}
void SetNumber( const wxString& aNumber ) { m_number = aNumber; } void SetNumber( const wxString& aNumber ) { m_number = aNumber; }
ELECTRICAL_PINTYPE GetType() const; ELECTRICAL_PINTYPE GetType() const;