From 8fc1346bf477df75e79c8c71a96e1f1ae6cf7a22 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 25 Aug 2015 13:53:43 +0300 Subject: [PATCH] Issue #769 fix: if selection is invalid, but must be updated, updated it. --- src/Model/Model_Update.cpp | 64 ++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 25dc969b7..d0b06ce0b 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -450,24 +450,23 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { list::iterator aRefsIter = aRefs.begin(); for (; aRefsIter != aRefs.end(); aRefsIter++) { std::shared_ptr aSel = - std::dynamic_pointer_cast(*aRefsIter); - bool isObligatory = !aFactory->isNotObligatory( - theFeature->getKind(), theFeature->data()->id(aSel)) && - aFactory->isCase(theFeature, theFeature->data()->id(aSel)); - if (aSel->isInvalid()) { - aState = ModelAPI_StateInvalidArgument; - } else { - ObjectPtr aContext = aSel->context(); - // update argument only if the referenced object is changed - if (aContext.get() && !aContext->isDisabled() && - (myJustUpdated.find(aContext) != myJustUpdated.end() || - aContext->data()->updateID() > theFeature->data()->updateID())) { - if (aState == ModelAPI_StateDone) - aState = ModelAPI_StateMustBeUpdated; - if (!aSel->update()) { // this must be done on execution since it may be long operation - if (isObligatory) - aState = ModelAPI_StateInvalidArgument; - } + std::dynamic_pointer_cast(*aRefsIter); + ObjectPtr aContext = aSel->context(); + // update argument only if the referenced object is changed + if (aContext.get() && !aContext->isDisabled()) { + bool isObligatory = !aFactory->isNotObligatory( + theFeature->getKind(), theFeature->data()->id(aSel)) && + aFactory->isCase(theFeature, theFeature->data()->id(aSel)); + if (myJustUpdated.find(aContext) != myJustUpdated.end() || + aContext->data()->updateID() > theFeature->data()->updateID()) { + if (aState == ModelAPI_StateDone) + aState = ModelAPI_StateMustBeUpdated; + if (!aSel->update()) { // this must be done on execution since it may be long operation + if (isObligatory) + aState = ModelAPI_StateInvalidArgument; + } + } else if (aSel->isInvalid()) { // not needed to update, but invalid (stated previously) + aState = ModelAPI_StateInvalidArgument; } } } @@ -479,23 +478,22 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { std::shared_ptr aSelAttr = std::dynamic_pointer_cast(aSel->value(a)); if (aSelAttr) { - bool isObligatory = !aFactory->isNotObligatory( - theFeature->getKind(), theFeature->data()->id(aSel)) && - aFactory->isCase(theFeature, theFeature->data()->id(aSel)); - if (aSelAttr->isInvalid()) { - aState = ModelAPI_StateInvalidArgument; - } else { - ObjectPtr aContext = aSelAttr->context(); - // update argument onlt if the referenced object is changed - if (aContext.get() && !aContext->isDisabled() && - (myJustUpdated.find(aContext) != myJustUpdated.end() || + ObjectPtr aContext = aSelAttr->context(); + // update argument onlt if the referenced object is changed + if (aContext.get() && !aContext->isDisabled()) { + bool isObligatory = !aFactory->isNotObligatory( + theFeature->getKind(), theFeature->data()->id(aSel)) && + aFactory->isCase(theFeature, theFeature->data()->id(aSel)); + if ((myJustUpdated.find(aContext) != myJustUpdated.end() || aContext->data()->updateID() > theFeature->data()->updateID())) { - if (aState == ModelAPI_StateDone) + if (aState == ModelAPI_StateDone) aState = ModelAPI_StateMustBeUpdated; - if (!aSelAttr->update()) { - if (isObligatory) - aState = ModelAPI_StateInvalidArgument; - } + if (!aSelAttr->update()) { + if (isObligatory) + aState = ModelAPI_StateInvalidArgument; + } + } else if (aSelAttr->isInvalid()) { + aState = ModelAPI_StateInvalidArgument; } } } -- 2.39.2