From 9f9e87f11f7d917460805b2d9d9e905dfdf004ed Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 18 Jun 2019 11:18:09 -0400 Subject: [PATCH] Minor library identifier validator change. Use the wxTextValidator style flag to allow the user to clear the library identifier string. Use wxTextValidator::SetStyle( wxFILTER_EMPTY ) to prevent empty library identifier strings which is the current behavior. --- common/validators.cpp | 6 +++++- include/validators.h | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/validators.cpp b/common/validators.cpp index 8574e141ed..5fd288774b 100644 --- a/common/validators.cpp +++ b/common/validators.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2018 CERN * @@ -291,6 +291,10 @@ bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent ) wxString val( text->GetValue() ); wxString tmp = val.Clone(); // For trailing and leading white space tests. + // Allow empty string if empty filter not set to allow clearing the LIB_ID. + if( !(GetStyle() & wxFILTER_EMPTY) && val.IsEmpty() ) + return true; + if( tmp.Trim() != val ) // Trailing white space. { msg = _( "Entry contains trailing white space." ); diff --git a/include/validators.h b/include/validators.h index 907a29d46c..6e71e34bba 100644 --- a/include/validators.h +++ b/include/validators.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2018 CERN * @@ -166,6 +166,9 @@ protected: /** * Custom validator that verifies that a string defines a valid #LIB_ID. + * + * The default validation allows empty #LIB_ID strings to allow the #LIB_ID to be cleared. + * Use SetStyle( wxFILTER_EMPTY ) to force a valid #LIB_ID string. */ class LIB_ID_VALIDATOR : public wxTextValidator {