]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3237: Use for names of objects letters, digits, '_' and space
authorvsv <vsv@opencascade.com>
Mon, 3 Aug 2020 09:56:01 +0000 (12:56 +0300)
committervsv <vsv@opencascade.com>
Mon, 3 Aug 2020 09:56:34 +0000 (12:56 +0300)
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_Tools.cpp

index 1938f9b79213a7e2165df356ae909789cfb0ae92..4c5cfc9ad0c08f2f4e41a59680ab1496081f3dee 100644 (file)
@@ -131,7 +131,6 @@ void XGUI_DataTree::commitData(QWidget* theEditor)
       if (XGUI_Tools::canRename(aObj, aName)) {
         SessionPtr aMgr = ModelAPI_Session::get();
         aMgr->startOperation("Rename");
-        std::wstring aaa = aName.toStdWString();
         aObj->data()->setName(aName.toStdWString());
         aMgr->finishOperation();
       }
index 96fa5f4b806f478ff780aabe2149bfbf931ef1e7..e04bc4547e2128eb019482b990707cdc2b492352 100644 (file)
@@ -182,6 +182,20 @@ bool isAscii(const QString& theStr)
   return true;
 }
 
+//******************************************************************
+bool isValidName(const QString& theName)
+{
+  QChar aChar;
+  for (int i = 0; i < theName.size(); i++) {
+    aChar = theName[i];
+    if (!aChar.isLetterOrNumber()) {
+      if ((aChar != "_") && (!aChar.isSpace()))
+        return false;
+    }
+  }
+  return true;
+}
+
 //******************************************************************
 bool canRename(const ObjectPtr& theObject, const QString& theName)
 {
@@ -205,6 +219,9 @@ bool canRename(const ObjectPtr& theObject, const QString& theName)
     }
   }
   else {
+    if (!isValidName(theName))
+      return false;
+
     DocumentPtr aDoc = theObject->document();
     ObjectPtr aObj =
       aDoc->objectByName(aType, theName.toStdWString());