Salome HOME
Issue #3058: Avoid recursive call of object redisplay
authorvsv <vsv@opencascade.com>
Wed, 6 Nov 2019 07:40:33 +0000 (10:40 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 07:40:33 +0000 (10:40 +0300)
src/Model/Model_AttributeIntArray.cpp
src/Model/Model_AttributeIntArray.h
src/ModelAPI/ModelAPI_AttributeIntArray.h
src/PartSet/PartSet_SketcherMgr.cpp

index b8da1694554e8dd85b36f4e86399e15f7eebef67..f933ad261408582eeb7b93f71b5267056377737a 100644 (file)
@@ -43,25 +43,28 @@ int Model_AttributeIntArray::size()
   return (myArray.IsNull() || !myArray->IsValid()) ? 0 : myArray->Length();
 }
 
-void Model_AttributeIntArray::setSize(const int theSize)
+void Model_AttributeIntArray::setSize(const int theSize, bool sendUpdated)
 {
   if (myArray.IsNull() || !myArray->IsValid()) { // create array if it is not done yet
     if (theSize != 0) { // if size is zero, nothing to do (null array means there is no array)
       myArray = TDataStd_IntegerArray::Set(myLab, 0, theSize - 1);
-      owner()->data()->sendAttributeUpdated(this);
+      if (sendUpdated)
+        owner()->data()->sendAttributeUpdated(this);
     }
   } else { // reset the old array
     if (theSize) {
       if (theSize != myArray->Length()) { // old data is not kept, a new array is created
         Handle(TColStd_HArray1OfInteger) aNewArray = new TColStd_HArray1OfInteger(0, theSize - 1);
         myArray->ChangeArray(aNewArray);
-        owner()->data()->sendAttributeUpdated(this);
+        if (sendUpdated)
+          owner()->data()->sendAttributeUpdated(this);
       }
     } else { // size is zero => array must be erased
       if (!myArray.IsNull()) {
         myArray.Nullify();
         myLab.ForgetAttribute(TDataStd_IntegerArray::GetID());
-        owner()->data()->sendAttributeUpdated(this);
+        if (sendUpdated)
+          owner()->data()->sendAttributeUpdated(this);
       }
     }
   }
index 1c7d10166bc49133baaedbdbb50fbd26d944c293..98040141e382df0fe83675cf12c6d6b661240e06 100644 (file)
@@ -47,7 +47,8 @@ class Model_AttributeIntArray : public ModelAPI_AttributeIntArray
   MODEL_EXPORT virtual int size();
 
   /// Sets the new size of the array. The previous data is erased.
-  MODEL_EXPORT virtual void setSize(const int theSize);
+  MODEL_EXPORT virtual void setSize(const int theSize,
+                                    bool sendUpdated = true);
 
   /// Defines the value of the array by index [0; size-1]
   MODEL_EXPORT virtual void setValue(const int theIndex,
index b8b146ff2b5532b094ecb3c29287e89b833c9704..e77841875dce26527cf8dc59cff944b3b14f2675 100644 (file)
@@ -40,7 +40,8 @@ class ModelAPI_AttributeIntArray : public ModelAPI_Attribute
   MODELAPI_EXPORT virtual int size() = 0;
 
   /// Sets the new size of the array. The previous data is erased.
-  MODELAPI_EXPORT virtual void setSize(const int theSize) = 0;
+  MODELAPI_EXPORT virtual void setSize(const int theSize,
+                                       bool sendUpdated = true) = 0;
 
   /// Defines the value of the array by index [0; size-1]
   MODELAPI_EXPORT virtual void setValue(const int theIndex,
index ea764c531ac7b6f9b05d57fc1b9210910b43aaa7..6bdb4a92b3e6d447dc01666444a5933eca8ef864 100644 (file)
@@ -2237,7 +2237,7 @@ void PartSet_SketcherMgr::customizeSketchPresentation(const ObjectPtr& theObject
     if (ModelAPI_Session::get()->isOperation()) {
       AttributeIntArrayPtr aColorAttr = theObject->data()->intArray(ModelAPI_Result::COLOR_ID());
       if (aColorAttr.get()) {
-        aColorAttr->setSize(3);
+        aColorAttr->setSize(3, false);
         // Set the color attribute in order do not use default colors in the presentation object
         for (int i = 0; i < 3; i++)
           aColorAttr->setValue(i, aColor[i], false);