From: vsv Date: Fri, 23 May 2014 13:18:16 +0000 (+0400) Subject: Fix of renaming function X-Git-Tag: V_0.2~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8ac5536248ed721f1b5f07d51bca2b900d18035a;p=modules%2Fshaper.git Fix of renaming function --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 03effc8e3..f794bda07 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -36,10 +36,21 @@ string Model_Data::getName() void Model_Data::setName(string theName) { - TDataStd_Name::Set(myLab, theName.c_str()); - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); - Events_Loop::loop()->send(aMsg, false); + bool isModified = false; + Handle(TDataStd_Name) aName; + if (!myLab.FindAttribute(TDataStd_Name::GetID(), aName)) { + TDataStd_Name::Set(myLab, theName.c_str()); + isModified = true; + } else { + isModified = !aName->Get().IsEqual(theName.c_str()); + if (isModified) + aName->Set(theName.c_str()); + } + if (isModified) { + static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); + Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); + Events_Loop::loop()->send(aMsg, false); + } } void Model_Data::addAttribute(string theID, string theAttrType) diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 702c44fef..258a59f80 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -83,12 +83,13 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (aEditor) { QString aRes = aEditor->text(); FeaturePtr aFeature = mySelectedData.first(); - aFeature->document()->startOperation(); + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + aMgr->rootDocument()->startOperation(); if (aFeature->data()) aFeature->data()->setName(qPrintable(aRes)); else boost::dynamic_pointer_cast(aFeature)->setName(qPrintable(aRes)); - aFeature->document()->finishOperation(); + aMgr->rootDocument()->finishOperation(); } }