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 {