From 1f5213946e8420cd3e28621e85232f3594d63811 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 8 Nov 2020 00:33:15 +0000 Subject: [PATCH] Restore accidentally-removed allowsSpaces architecture. Fixes https://gitlab.com/kicad/code/kicad/issues/6252 --- common/validators.cpp | 15 ++++++++++++--- eeschema/dialogs/dialog_edit_label.cpp | 2 +- eeschema/sch_validators.h | 4 ++++ include/validators.h | 5 +++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/common/validators.cpp b/common/validators.cpp index e0141d8e80..b3b3cc3397 100644 --- a/common/validators.cpp +++ b/common/validators.cpp @@ -317,13 +317,22 @@ bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent ) NETNAME_VALIDATOR::NETNAME_VALIDATOR( wxString *aVal ) : - wxTextValidator() + wxTextValidator(), + m_allowSpaces( false ) { } NETNAME_VALIDATOR::NETNAME_VALIDATOR( const NETNAME_VALIDATOR& aValidator ) : - wxTextValidator( aValidator ) + wxTextValidator( aValidator ), + m_allowSpaces( aValidator.m_allowSpaces ) +{ +} + + +NETNAME_VALIDATOR::NETNAME_VALIDATOR( bool aAllowSpaces ) : + wxTextValidator(), + m_allowSpaces( aAllowSpaces ) { } @@ -357,7 +366,7 @@ wxString NETNAME_VALIDATOR::IsValid( const wxString& str ) const if( str.Contains( '\r' ) || str.Contains( '\n' ) ) return _( "Signal names cannot contain CR or LF characters" ); - if( str.Contains( ' ' ) || str.Contains( '\t' ) ) + if( !m_allowSpaces && ( str.Contains( ' ' ) || str.Contains( '\t' ) ) ) return _( "Signal names cannot contain spaces" ); return wxString(); diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 8f813e6e33..230b6a2ccb 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -48,7 +48,7 @@ class SCH_TEXT; DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : DIALOG_LABEL_EDITOR_BASE( aParent ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), - m_netNameValidator(), + m_netNameValidator( true ), m_scintillaTricks( nullptr ), m_helpWindow( nullptr ) { diff --git a/eeschema/sch_validators.h b/eeschema/sch_validators.h index 3b22ae2afb..6bbc379176 100644 --- a/eeschema/sch_validators.h +++ b/eeschema/sch_validators.h @@ -81,6 +81,10 @@ public: NETNAME_VALIDATOR( aVal ) { } + SCH_NETNAME_VALIDATOR( bool aAllowSpaces ) : + NETNAME_VALIDATOR( aAllowSpaces ) + { } + SCH_NETNAME_VALIDATOR( const SCH_NETNAME_VALIDATOR& aValidator ) : NETNAME_VALIDATOR( aValidator ) { } diff --git a/include/validators.h b/include/validators.h index 4a9ac7f874..c3fc1635ca 100644 --- a/include/validators.h +++ b/include/validators.h @@ -200,6 +200,8 @@ class NETNAME_VALIDATOR : public wxTextValidator public: NETNAME_VALIDATOR( wxString *aVal = nullptr ); + NETNAME_VALIDATOR( bool aAllowSpaces ); + NETNAME_VALIDATOR( const NETNAME_VALIDATOR& aValidator ); virtual wxObject* Clone() const override { return new NETNAME_VALIDATOR( *this ); } @@ -213,6 +215,9 @@ public: protected: // returns the error message if the contents of 'val' are invalid wxString IsValid( const wxString& aVal ) const override; + +private: + bool m_allowSpaces; };