Salome HOME
Exlude the user input during process events by application (Bug #325).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_NameValidator.cxx
index 5c6630410c319a6ebcea625addae20dd851352b8..4c029fc72113daed44fa693b39c6d5b3056fbe27 100644 (file)
@@ -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 )