From 76a0d4c4c0dcdbba967356832cc36e6a8c09e470 Mon Sep 17 00:00:00 2001 From: PJM Date: Sun, 8 Jan 2023 16:51:46 -0800 Subject: [PATCH] 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 --- eeschema/lib_pin.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 759685b697..969dbd6e88 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1340,13 +1340,20 @@ BITMAPS LIB_PIN::GetMenuImage() 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( !m_name.IsEmpty() ) + if ( !shownName.IsEmpty() ) { return wxString::Format( _( "Pin %s [%s, %s, %s]" ), GetShownNumber(), - UnescapeString( GetShownName() ), + shownName, GetElectricalTypeName(), PinShapeGetText( m_shape ) ); } @@ -1360,11 +1367,11 @@ wxString LIB_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const } else { - if( !m_name.IsEmpty() ) + if( !shownName.IsEmpty() ) { return wxString::Format( _( "Hidden pin %s [%s, %s, %s]" ), GetShownNumber(), - UnescapeString( GetShownName() ), + shownName, GetElectricalTypeName(), PinShapeGetText( m_shape ) ); }