From c5352903243a909771af75a675bf16601301720c Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 10 Jan 2019 15:27:32 +0300 Subject: [PATCH] Issue #2754: Objects of the same type can not have the same name. --- src/XGUI/XGUI_Tools.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index aafafbfce..e058ff8cf 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -166,16 +166,14 @@ bool canRename(const ObjectPtr& theObject, const QString& theName) return false; } } - else if ((aType == ModelAPI_ResultConstruction::group()) || - (aType == ModelAPI_ResultBody::group())) { + else { DocumentPtr aDoc = theObject->document(); ObjectPtr aObj = - aDoc->objectByName(ModelAPI_ResultConstruction::group(), theName.toStdString()); - if (!aObj.get()) - aObj = aDoc->objectByName(ModelAPI_ResultBody::group(), theName.toStdString()); + aDoc->objectByName(aType, theName.toStdString()); if (aObj.get()) { - QString aErrMsg(QObject::tr("Object with name %1 already exists.").arg(theName)); + QString aErrMsg(QObject::tr("%1 with name %2 already exists."). + arg(aType.c_str()).arg(theName)); // We can not use here a dialog box for message - // it will crash editing process in ObjectBrowser Events_InfoMessage("XGUI_Tools", aErrMsg.toStdString()).send(); -- 2.39.2