From b011d40eb8851e43f811abf6ac213c6580d83ef7 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 12 Apr 2016 09:18:42 +0300 Subject: [PATCH] Stop the infinitive cycling loop in update if bad dependencies graph presented in the tree. --- src/Model/Model_Update.cpp | 12 ++++++++++++ src/Model/Model_Update.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index bb7b68163..ae28fb724 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -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 diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 106b48cbc..c9fe39ab7 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -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 > myProcessOnFinish; - + /// to avoid infinitive cycling: feature -> count of the processing periods during this update + std::map, int > myProcessed; public: /// Is called only once, on startup of the application -- 2.39.2