From: vsv Date: Mon, 3 Aug 2020 09:56:01 +0000 (+0300) Subject: Issue #3237: Use for names of objects letters, digits, '_' and space X-Git-Tag: V9_6_0a1~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3577628501b5a25b34216d63641df4348f648953;p=modules%2Fshaper.git Issue #3237: Use for names of objects letters, digits, '_' and space --- diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 1938f9b79..4c5cfc9ad 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -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(); } diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index 96fa5f4b8..e04bc4547 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -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());