X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_NameValidator.cxx;h=4c029fc72113daed44fa693b39c6d5b3056fbe27;hb=f34b90e9e4e02ba65419134d5d37a2e42aecfabf;hp=5c6630410c319a6ebcea625addae20dd851352b8;hpb=f99b39f1b9dbf6939a1c605331c250dd8d59e897;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_NameValidator.cxx b/src/HYDROGUI/HYDROGUI_NameValidator.cxx index 5c663041..4c029fc7 100644 --- a/src/HYDROGUI/HYDROGUI_NameValidator.cxx +++ b/src/HYDROGUI/HYDROGUI_NameValidator.cxx @@ -38,18 +38,21 @@ QValidator::State HYDROGUI_NameValidator::validate( QString & theName, int & the State aRes = Acceptable; QString aName = theName.simplified(); - if ( aName.isEmpty() ) + if( !myEditedObject.IsNull() ) // To avoid problems when myEditedObject is not set yet { - aRes = Intermediate; - } - else if( !myEditedObject.IsNull() && myEditedObject->GetName() != theName ) - { - // check that there are no other objects with the same name in the document - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( myModule, aName ); - if ( !anObject.IsNull() ) + if ( aName.isEmpty() ) { aRes = Intermediate; } + else if( myEditedObject->GetName() != theName ) + { + // check that there are no other objects with the same name in the document + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( myModule, aName ); + if ( !anObject.IsNull() ) + { + aRes = Intermediate; + } + } } return aRes; @@ -67,7 +70,10 @@ void HYDROGUI_NameValidator::fixup( QString & theName ) const emit alreadyExists( theName ); } - theName = myEditedObject->GetName(); + if( !myEditedObject.IsNull() ) + { + theName = myEditedObject->GetName(); + } } void HYDROGUI_NameValidator::setEditedObject( const Handle(HYDROData_Entity) theObj )