]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Stop the infinitive cycling loop in update if bad dependencies graph presented in...
authormpv <mpv@opencascade.com>
Tue, 12 Apr 2016 06:18:42 +0000 (09:18 +0300)
committermpv <mpv@opencascade.com>
Tue, 12 Apr 2016 06:18:42 +0000 (09:18 +0300)
src/Model/Model_Update.cpp
src/Model/Model_Update.h

index bb7b681638d2dce66427b00a3e3ae8071e12a009..ae28fb7243c552a8ace4bf942b21b1363acab815 100644 (file)
@@ -302,6 +302,18 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
       return false;
   }
 
+  if (myProcessed.find(theFeature) == myProcessed.end()) {
+    myProcessed[theFeature] = 0;
+  } else {
+    int aCount = myProcessed[theFeature];
+    if (aCount > 100) { // too many repetition of processing (in VS it may crash on 330 with stack overflow)
+      Events_Error::send(
+        "Feature '" + theFeature->data()->name() + "' is updtated in infinitive loop");
+      return false;
+    }
+    myProcessed[theFeature] = aCount + 1;
+  }
+
   // check this feature is not yet checked or processed
   bool aIsModified = myModified.find(theFeature) != myModified.end();
   if (!aIsModified && myIsFinish) { // get info about the modification for features without preview
index 106b48cbcd366180f0075325dda3a213246f610d..c9fe39ab7178ee1e1f01d07e215b22eafd17b654 100644 (file)
@@ -39,7 +39,8 @@ class Model_Update : public Events_Listener
   bool myIsProcessed;
   /// set that contains features that must be executed only on finish of the operation
   std::set<std::shared_ptr<ModelAPI_Feature> > myProcessOnFinish;
-
+  /// to avoid infinitive cycling: feature -> count of the processing periods during this update
+  std::map<std::shared_ptr<ModelAPI_Feature>, int > myProcessed;
 
  public:
   /// Is called only once, on startup of the application