Fix validation of net names in eeschema
The SCH_NETNAME_VALIDATOR wasn't even being used because C++ is great Fixes https://gitlab.com/kicad/code/kicad/-/issues/1821
This commit is contained in:
parent
e95323a37e
commit
fc96cb90f1
|
@ -202,14 +202,29 @@ bool SCH_FIELD_VALIDATOR::Validate( wxWindow* aParent )
|
|||
}
|
||||
|
||||
|
||||
wxRegEx SCH_NETNAME_VALIDATOR::m_busGroupRegex( R"([^$]?{)", wxRE_ADVANCED );
|
||||
|
||||
|
||||
wxString SCH_NETNAME_VALIDATOR::IsValid( const wxString& str ) const
|
||||
{
|
||||
if( NET_SETTINGS::ParseBusGroup( str, nullptr, nullptr ) )
|
||||
// We don't do single-character validation here
|
||||
if( str.Length() == 1 )
|
||||
return wxString();
|
||||
|
||||
if( ( str.Contains( '[' ) || str.Contains( ']' ) ) &&
|
||||
!NET_SETTINGS::ParseBusVector( str, nullptr, nullptr ) )
|
||||
{
|
||||
return _( "Signal name contains '[' or ']' but is not a valid vector bus name" );
|
||||
}
|
||||
|
||||
// Figuring out if the user "meant" to make a bus group is somewhat trickier because angle
|
||||
// brackets are also used for variable expansion
|
||||
|
||||
if( m_busGroupRegex.Matches( str ) && str.Contains( '}' ) &&
|
||||
!NET_SETTINGS::ParseBusGroup( str, nullptr, nullptr ) )
|
||||
{
|
||||
return _( "Signal name contains '{' and '}' but is not a valid group bus name" );
|
||||
}
|
||||
|
||||
return NETNAME_VALIDATOR::IsValid( str );
|
||||
}
|
||||
|
|
|
@ -90,9 +90,14 @@ public:
|
|||
NETNAME_VALIDATOR( aValidator )
|
||||
{ }
|
||||
|
||||
virtual wxObject* Clone() const override { return new SCH_NETNAME_VALIDATOR( *this ); }
|
||||
|
||||
protected:
|
||||
/// @return the error message if the contents of \a aVal are invalid.
|
||||
wxString IsValid( const wxString& aVal ) const override;
|
||||
|
||||
private:
|
||||
static wxRegEx m_busGroupRegex;
|
||||
};
|
||||
|
||||
#endif // _SCH_VALIDATORS_H_
|
||||
|
|
Loading…
Reference in New Issue