From a924961429b3337991652f7d6f3be7b1148ed601 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 13 May 2015 11:57:56 +0300 Subject: [PATCH] Make features enabled/disabled in the correct way --- src/Model/Model_Document.cpp | 7 +++++-- src/Model/Model_Update.cpp | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 238b0f3e6..b5ee4b75b 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -599,6 +599,7 @@ FeaturePtr Model_Document::addFeature(std::string theID) // event: feature is added static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); + aFeature->setDisabled(false); // by default created feature is enabled setCurrentFeature(aFeature); // after all this feature stays in the document, so make it current } else { // feature must be executed // no creation event => updater not working, problem with remove part @@ -998,14 +999,16 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr for(int a = aSize - 1; a >= 0; a--) { FeaturePtr aFeature = std::dynamic_pointer_cast(object(ModelAPI_Feature::group(), a, true)); + + // check this before passed become enabled: the current feature is enabled! + if (aFeature == theCurrent) aPassed = true; + if (aFeature->setDisabled(!aPassed)) { // state of feature is changed => so feature become updated static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(aFeature, anUpdateEvent); } - // check this only after passed become enabled: the current feature is enabled! - if (aFeature == theCurrent) aPassed = true; } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 93f50a171..72daf2082 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -234,6 +234,8 @@ ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecStat void Model_Update::updateArguments(FeaturePtr theFeature) { static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); + if (theFeature->isDisabled()) // nothing to do with disabled feature + return; bool aJustUpdated = false; ModelAPI_ExecState aState = ModelAPI_StateDone; // check the parameters: values can be changed @@ -299,6 +301,9 @@ void Model_Update::updateFeature(FeaturePtr theFeature) { // check all features this feature depended on (recursive call of updateFeature) static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); + + if (theFeature->isDisabled()) // nothing to do with disabled feature + return; bool aJustUpdated = false; if (theFeature) { -- 2.39.2