From f992d144d9075d3966bb25641f8b7fa23a22cba0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 28 Nov 2017 21:02:00 +0100 Subject: [PATCH] Eeschema, LIB_PIN::SetNumber(): ensure spaces are replaced by _ and set modify flag on change. Fixes: lp:1734187 https://bugs.launchpad.net/kicad/+bug/1734187 --- eeschema/lib_pin.cpp | 20 ++++++++++++++++++++ eeschema/lib_pin.h | 5 +---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 1743702fd4..727cd89bfc 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -161,6 +161,7 @@ void LIB_PIN::SetName( const wxString& aName, bool aTestOtherPins ) { wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName; + // pin name string does not support spaces tmp.Replace( wxT( " " ), wxT( "_" ) ); if( m_name != tmp ) @@ -217,6 +218,25 @@ void LIB_PIN::SetNameTextSize( int size, bool aTestOtherPins ) } +void LIB_PIN::SetNumber( const wxString& aNumber ) +{ + // Unlike SetName, others pin numbers marked by EnableEditMode() are + // not modified because each pin has its own number, so set number + // only for this. + + wxString tmp = ( aNumber.IsEmpty() ) ? wxT( "~" ) : aNumber; + + // pin number string does not support spaces + tmp.Replace( wxT( " " ), wxT( "_" ) ); + + if( m_number != tmp ) + { + m_number = tmp; + SetModified(); + } +} + + void LIB_PIN::SetNumberTextSize( int size, bool aTestOtherPins ) { if( size != m_numTextSize ) diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 4c5a8deb87..f5558010a6 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -198,10 +198,7 @@ public: * because each pin has its own number * @param aNumber New pin number. */ - void SetNumber( const wxString& aNumber ) - { - m_number = aNumber; - } + void SetNumber( const wxString& aNumber ); /** * Set the size of the pin number text.