Eeeschema: Fixed logic to display unamed pins properly

CHANGED:  This code previously checked "m_name.IsEmpty()" to choose the
correct formatting path, but that check fails if the pin is called "~"
which is the default for an empty pin name.  Instead we get the final
display string that will be shown and check if it's empty.

Fixes https://gitlab.com/kicad/code/kicad/issues/13332
This commit is contained in:
PJM 2023-01-08 16:51:46 -08:00 committed by Seth Hillbrand
parent a206f6717d
commit 76a0d4c4c0
1 changed files with 11 additions and 4 deletions

View File

@ -1340,13 +1340,20 @@ BITMAPS LIB_PIN::GetMenuImage() const
wxString LIB_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const wxString LIB_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
{ {
// This code previously checked "m_name.IsEmpty()" to choose the correct
// formatting path, but that check fails if the pin is called "~" which is
// the default for an empty pin name. Instead we get the final display string
// that will be shown and check if it's empty.
wxString shownName = UnescapeString( GetShownName() );
if( IsVisible() ) if( IsVisible() )
{ {
if( !m_name.IsEmpty() ) if ( !shownName.IsEmpty() )
{ {
return wxString::Format( _( "Pin %s [%s, %s, %s]" ), return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
GetShownNumber(), GetShownNumber(),
UnescapeString( GetShownName() ), shownName,
GetElectricalTypeName(), GetElectricalTypeName(),
PinShapeGetText( m_shape ) ); PinShapeGetText( m_shape ) );
} }
@ -1360,11 +1367,11 @@ wxString LIB_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
} }
else else
{ {
if( !m_name.IsEmpty() ) if( !shownName.IsEmpty() )
{ {
return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ), return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ),
GetShownNumber(), GetShownNumber(),
UnescapeString( GetShownName() ), shownName,
GetElectricalTypeName(), GetElectricalTypeName(),
PinShapeGetText( m_shape ) ); PinShapeGetText( m_shape ) );
} }