Salome HOME
Fix for the issue #1156
[modules/shaper.git] / src / Model / Model_Update.cpp
index e6d83e1970dbeebf619f32df6eb8dd12dc871bf1..9d655c03c64a57db054c18350b13bd99554b50fc 100644 (file)
@@ -172,7 +172,8 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
     // place where results are cleared)
     myIsParamUpdated = false;
     myUpdated.clear();
-    myModification = 0;
+    // do not erase it since there may be modification increment on start of operation
+    //myModification = 0;
     myWaitForFinish.clear();
   }
 }
@@ -240,6 +241,8 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin
       isAutomaticChanged = true;
       myIsAutomatic = true;
     }
+    // modifications inside of the iteration will be different from modification that comes outside
+    myModification++;
     // init iteration from the root document
     iterateUpdate(CompositeFeaturePtr());
 
@@ -455,6 +458,9 @@ bool Model_Update::isOlder(std::shared_ptr<ModelAPI_Feature> theFeature,
     std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
     if (!aRes->isDisabled()) {
       std::map<std::shared_ptr<ModelAPI_Object>, int >::iterator anRIter = myUpdated.find(aRes);
+      int aResultID = aRes->data()->updateID();
+      if (aResultID < anArgID)
+        return true;
       if (anRIter == myUpdated.end()) // not updated at all
         return true;
       if (anRIter->second < anAIter->second)
@@ -658,13 +664,14 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
       aState = ModelAPI_StateExecFailed;
     } else {
       aState = ModelAPI_StateDone;
-      myWaitForFinish.insert(theFeature);
     }
   } catch(...) {
     aState = ModelAPI_StateExecFailed;
     Events_Error::send(
       "Feature " + theFeature->getKind() + " has failed during the execution");
   }
+  // The macro feature has to be deleted in any case even its execution is failed 
+  myWaitForFinish.insert(theFeature);
   if (aState != ModelAPI_StateDone) {
     theFeature->eraseResults();
   }