diff --git a/Changes.md b/Changes.md index 063419f08d..bd6af8aa17 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,11 @@ 1.4.x.x (relative to 1.4.12.0) ======= +Improvements +------------ + +- NodeEditor, NameWidget : Invalid characters are automatically converted to `_` when renaming a node or plug, and `:` is no longer treated as invalid. + Fixes ----- diff --git a/python/GafferUI/NameWidget.py b/python/GafferUI/NameWidget.py index 950070522d..ca0289dbdf 100644 --- a/python/GafferUI/NameWidget.py +++ b/python/GafferUI/NameWidget.py @@ -125,18 +125,17 @@ def __plugMetadataChanged( self, plug, key, reason ) : class _Validator( QtGui.QValidator ) : + __invalidCharacters = re.compile( "[^A-Za-z_:0-9]" ) + def __init__( self, parent ) : QtGui.QValidator.__init__( self, parent ) def validate( self, input, pos ) : - input = input.replace( " ", "_" ) + input = self.__invalidCharacters.sub( "_", input ) if len( input ) : - if re.match( "^(?!__)[A-Za-z_]+[A-Za-z_0-9]*$", input ) : - result = QtGui.QValidator.Acceptable - else : - result = QtGui.QValidator.Invalid + result = QtGui.QValidator.Acceptable else : result = QtGui.QValidator.Intermediate diff --git a/src/Gaffer/GraphComponent.cpp b/src/Gaffer/GraphComponent.cpp index 86d258c577..e16b9a338b 100644 --- a/src/Gaffer/GraphComponent.cpp +++ b/src/Gaffer/GraphComponent.cpp @@ -69,6 +69,7 @@ namespace /// \todo Relax restrictions to only disallow '.' and `/'? We originally had /// these strict requirements because we accessed GraphComponent children /// as attributes in Python, but that approach has long since gone. +/// When doing this, also update the validator in NameWidget. bool validName( const std::string &name ) { if( name.empty() )