From a5b5396519d8a09dbb34325fa0eca7de18732c84 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 4 Apr 2017 14:27:38 +0300 Subject: [PATCH] Issue #2052 : really remove results if during the feature execution number of results becomes smaller. --- src/Model/Model_AttributeSelection.cpp | 2 +- src/Model/Model_Objects.cpp | 1 - src/Model/Model_Update.cpp | 6 +++--- src/ModelAPI/ModelAPI_Feature.cpp | 19 ++++++++++--------- src/ModelAPI/ModelAPI_Feature.h | 6 ++++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 513c39d5c..b2a4989db 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -538,7 +538,7 @@ void Model_AttributeSelection::selectBody( if (aFeatureOwner.get()) { aEraseResults = !aFeatureOwner->results().empty(); if (aEraseResults) // erase results without flash deleted and redisplay: do it after Select - aFeatureOwner->removeResults(0, false); + aFeatureOwner->removeResults(0, false, false); } aSel.Select(aNewSub, aNewContext); diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 798e234c5..f635941b3 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -75,7 +75,6 @@ Model_Objects::~Model_Objects() ModelAPI_EventCreator::get()->sendDeleted(myDoc, ModelAPI_Feature::group()); ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP); aFeature->removeResults(0, false); - //aFeature->eraseResults(); aFeature->erase(); myFeatures.UnBind(aFeaturesIter.Key()); } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 2c18d72bc..ee2e42be8 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -580,7 +580,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature) #ifdef DEB_UPDATE std::cout<<"Invalid args "<name()<eraseResults(); + theFeature->eraseResults(false); redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated return true; // so, feature is modified (results are erased) } @@ -595,7 +595,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature) #ifdef DEB_UPDATE std::cout<<"Feature is not valid, erase results "<name()<eraseResults(); + theFeature->eraseResults(false); redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated } return true; @@ -847,7 +847,7 @@ void Model_Update::executeFeature(FeaturePtr theFeature) // The macro feature has to be deleted in any case even its execution is failed myWaitForFinish.insert(theFeature); if (aState != ModelAPI_StateDone) { - theFeature->eraseResults(); + theFeature->eraseResults(false); } theFeature->data()->setUpdateID(ModelAPI_Session::get()->transactionID()); redisplayWithResults(theFeature, aState); diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index bb387f81c..f83cf00a8 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -104,7 +104,8 @@ void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr >::iterator aResIter = myResults.begin(); for(int anIndex = 0; anIndex < theSinceIndex && aResIter != myResults.end(); anIndex++) @@ -115,12 +116,12 @@ void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlus while( aNextIter != myResults.end()) { aGroup = (*aNextIter)->groupName(); // remove previously erased results: to enable later if needed only actual (of history change) - //if (theSinceIndex == 0 && (*aNextIter)->isDisabled()) { - // aNextIter = myResults.erase(aNextIter); - //} else { - (*aNextIter)->setDisabled(*aNextIter, true); // just disable results + (*aNextIter)->setDisabled(*aNextIter, true); // just disable results + if (theForever) { + aNextIter = myResults.erase(aNextIter); + } else { aNextIter++; - //} + } } if (!aGroup.empty() && theFlush) { // flush visualisation changes @@ -132,9 +133,9 @@ void ModelAPI_Feature::removeResults(const int theSinceIndex, const bool theFlus } } -void ModelAPI_Feature::eraseResults() +void ModelAPI_Feature::eraseResults(const bool theForever) { - removeResults(0); + removeResults(0, theForever, true); } const std::string& ModelAPI_Feature::documentToAdd() @@ -192,7 +193,7 @@ bool ModelAPI_Feature::setDisabled(const bool theFlag) if (myIsDisabled != theFlag) { myIsDisabled = theFlag; if (myIsDisabled) { - removeResults(0, false); // flush will be in setCurrentFeature + removeResults(0, false, false); // flush will be in setCurrentFeature } else { // enable all disabled previously results std::list >::iterator aResIter = myResults.begin(); diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 71bd251d8..e30978a69 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -87,10 +87,12 @@ class ModelAPI_Feature : public ModelAPI_Object MODELAPI_EXPORT void removeResult(const std::shared_ptr& theResult); /// removes all results starting from the given index (zero-based) /// \param theSinceIndex - index of the deleted result and all after also will be deleted + /// \param theForever - removes results for long period (not just because of feature disabling) /// \param theFlush - if it is false, REDISPLAY message is not flushed - MODELAPI_EXPORT void removeResults(const int theSinceIndex, const bool theFlush = true); + MODELAPI_EXPORT void removeResults(const int theSinceIndex, + const bool theForever = true, const bool theFlush = true); /// removes all results from the feature - MODELAPI_EXPORT void eraseResults(); + MODELAPI_EXPORT void eraseResults(const bool theForever = true); /// removes all fields from this feature: results, data, etc MODELAPI_EXPORT virtual void erase(); /// removes the result from the list of feature (not doing in disabled): normally this -- 2.39.2