From: mpv Date: Tue, 25 Aug 2015 10:53:43 +0000 (+0300) Subject: Issue #769 fix: if selection is invalid, but must be updated, updated it. X-Git-Tag: V_1.4.0_beta4~253 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8fc1346bf477df75e79c8c71a96e1f1ae6cf7a22;p=modules%2Fshaper.git Issue #769 fix: if selection is invalid, but must be updated, updated it. --- 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; } } }