Retire LIB_ID_VALIDATOR as it prevents usage of text variables.
(We perform more complete checks in ERC anyway.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/14764
This commit is contained in:
parent
90c4b8bc57
commit
421d6b2ef8
|
@ -268,54 +268,6 @@ void REGEX_VALIDATOR::compileRegEx( const wxString& aRegEx, int aFlags )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent )
|
|
||||||
{
|
|
||||||
LIB_ID dummy;
|
|
||||||
|
|
||||||
// If window is disabled, simply return
|
|
||||||
if( !m_validatorWindow->IsEnabled() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
wxTextEntry* const text = GetTextEntry();
|
|
||||||
|
|
||||||
if( !text )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
wxString msg;
|
|
||||||
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." );
|
|
||||||
}
|
|
||||||
else if( tmp.Trim( false ) != val ) // Leading white space.
|
|
||||||
{
|
|
||||||
msg = _( "Entry contains leading white space." );
|
|
||||||
}
|
|
||||||
else if( dummy.Parse( val ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID.
|
|
||||||
{
|
|
||||||
msg.Printf( _( "'%s' is not a valid library identifier format." ), val );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !msg.empty() )
|
|
||||||
{
|
|
||||||
m_validatorWindow->SetFocus();
|
|
||||||
|
|
||||||
wxMessageBox( msg, _( "Library Identifier Validation Error" ),
|
|
||||||
wxOK | wxICON_EXCLAMATION, aParent );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NETNAME_VALIDATOR::NETNAME_VALIDATOR( wxString *aVal ) :
|
NETNAME_VALIDATOR::NETNAME_VALIDATOR( wxString *aVal ) :
|
||||||
wxTextValidator(),
|
wxTextValidator(),
|
||||||
m_allowSpaces( false )
|
m_allowSpaces( false )
|
||||||
|
|
|
@ -100,7 +100,6 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
|
||||||
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
||||||
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
|
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
|
||||||
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
||||||
m_libIdValidator(),
|
|
||||||
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
|
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
|
||||||
|
@ -122,7 +121,6 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a
|
||||||
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
||||||
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
|
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
|
||||||
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
||||||
m_libIdValidator(),
|
|
||||||
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
|
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
|
||||||
|
@ -143,7 +141,6 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a
|
||||||
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
||||||
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
|
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
|
||||||
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
|
||||||
m_libIdValidator(),
|
|
||||||
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )
|
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )
|
||||||
|
@ -164,7 +161,6 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a
|
||||||
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
|
||||||
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ),
|
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ),
|
||||||
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ),
|
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ),
|
||||||
m_libIdValidator(),
|
|
||||||
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
|
||||||
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 )
|
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 )
|
||||||
|
@ -200,7 +196,7 @@ void FIELDS_GRID_TABLE<T>::initGrid( WX_GRID* aGrid )
|
||||||
|
|
||||||
m_footprintAttr = new wxGridCellAttr;
|
m_footprintAttr = new wxGridCellAttr;
|
||||||
GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, m_symbolNetlist );
|
GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, m_symbolNetlist );
|
||||||
fpIdEditor->SetValidator( m_libIdValidator );
|
fpIdEditor->SetValidator( m_nonUrlValidator );
|
||||||
m_footprintAttr->SetEditor( fpIdEditor );
|
m_footprintAttr->SetEditor( fpIdEditor );
|
||||||
|
|
||||||
m_urlAttr = new wxGridCellAttr;
|
m_urlAttr = new wxGridCellAttr;
|
||||||
|
|
|
@ -128,7 +128,6 @@ private:
|
||||||
SCH_FIELD_VALIDATOR m_fieldNameValidator;
|
SCH_FIELD_VALIDATOR m_fieldNameValidator;
|
||||||
SCH_FIELD_VALIDATOR m_referenceValidator;
|
SCH_FIELD_VALIDATOR m_referenceValidator;
|
||||||
SCH_FIELD_VALIDATOR m_valueValidator;
|
SCH_FIELD_VALIDATOR m_valueValidator;
|
||||||
LIB_ID_VALIDATOR m_libIdValidator;
|
|
||||||
SCH_FIELD_VALIDATOR m_urlValidator;
|
SCH_FIELD_VALIDATOR m_urlValidator;
|
||||||
SCH_FIELD_VALIDATOR m_nonUrlValidator;
|
SCH_FIELD_VALIDATOR m_nonUrlValidator;
|
||||||
SCH_FIELD_VALIDATOR m_filepathValidator;
|
SCH_FIELD_VALIDATOR m_filepathValidator;
|
||||||
|
|
|
@ -170,34 +170,6 @@ protected:
|
||||||
wxRegEx m_regEx;
|
wxRegEx m_regEx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @param aLibIdType is the type of #LIB_ID object to validate.
|
|
||||||
* @param aValue is a pointer to a wxString containing the value to validate.
|
|
||||||
*/
|
|
||||||
LIB_ID_VALIDATOR( wxString* aValue = nullptr ) :
|
|
||||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
|
||||||
{
|
|
||||||
SetCharExcludes( wxT( "\r\n\t" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual wxObject* Clone() const override
|
|
||||||
{
|
|
||||||
return new LIB_ID_VALIDATOR( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Validate( wxWindow* aParent ) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class NETNAME_VALIDATOR : public wxTextValidator
|
class NETNAME_VALIDATOR : public wxTextValidator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue