]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix of renaming function
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 13:18:16 +0000 (17:18 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 23 May 2014 13:18:16 +0000 (17:18 +0400)
src/Model/Model_Data.cpp
src/XGUI/XGUI_ObjectsBrowser.cpp

index 03effc8e3c9058cfb99083ea373862931075cde2..f794bda07c143f0936ff573d656542285969b459 100644 (file)
@@ -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)
index 702c44fef8cd696cfcff8fb55c68b14ca98dfec1..258a59f8021fe2b6663f57dbac02b351f4151dad 100644 (file)
@@ -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<ModelAPI_Object>(aFeature)->setName(qPrintable(aRes));
-    aFeature->document()->finishOperation();
+    aMgr->rootDocument()->finishOperation();
   }
 }