Salome HOME
Fix for the issue #1179
authormpv <mpv@opencascade.com>
Fri, 25 Dec 2015 18:16:49 +0000 (21:16 +0300)
committermpv <mpv@opencascade.com>
Fri, 25 Dec 2015 18:16:49 +0000 (21:16 +0300)
src/Model/Model_Data.cpp
src/Model/Model_Data.h

index 42f04f66aa88fba4408115caedc3c4aa15ee3925..067b3c6dfba39d2175def1ee3e5be4415ef9ffb7 100644 (file)
@@ -61,7 +61,7 @@ static const int kFlagDeleted = 2;
 // invalid data
 const static std::shared_ptr<ModelAPI_Data> kInvalid(new Model_Data());
 
-Model_Data::Model_Data() : mySendAttributeUpdated(true)
+Model_Data::Model_Data() : mySendAttributeUpdated(true), myWasChangedButBlocked(false)
 {
 }
 
@@ -268,17 +268,28 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
 {
   theAttr->setInitialized();
   if (theAttr->isArgument()) {
-    static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
-    ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
-    if (mySendAttributeUpdated && myObject) {
-      myObject->attributeChanged(theAttr->id());
+    if (mySendAttributeUpdated) {
+      if (myObject) {
+        myObject->attributeChanged(theAttr->id());
+        static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+        ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+      }
+    } else {
+      myWasChangedButBlocked = true;
     }
   }
 }
 
 void Model_Data::blockSendAttributeUpdated(const bool theBlock)
 {
-  mySendAttributeUpdated = !theBlock;
+  if (mySendAttributeUpdated == theBlock) {
+    mySendAttributeUpdated = !theBlock;
+    if (mySendAttributeUpdated && myWasChangedButBlocked) { // so, now it is ok to send the update signal
+      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+      ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
+      myWasChangedButBlocked = false;
+    }
+  }
 }
 
 void Model_Data::erase()
index da40e7d4a8de9e5247bd08e92167765da748209c..136ffd557c211d0f47c29118d5595596a05b486c 100644 (file)
@@ -55,6 +55,8 @@ class Model_Data : public ModelAPI_Data
   std::set<AttributePtr> myRefsToMe;
   /// flag that may block the "attribute updated" sending
   bool mySendAttributeUpdated;
+  /// if some attribute was changed, but mySendAttributeUpdated was false, this flag stores this
+  bool myWasChangedButBlocked;
 
   /// Returns label of this feature
   TDF_Label label()