Salome HOME
Issue #769 fix: if selection is invalid, but must be updated, updated it.
authormpv <mpv@opencascade.com>
Tue, 25 Aug 2015 10:53:43 +0000 (13:53 +0300)
committermpv <mpv@opencascade.com>
Tue, 25 Aug 2015 10:53:43 +0000 (13:53 +0300)
src/Model/Model_Update.cpp

index 25dc969b772a40a6ca7fe186bca68c13a24f688f..d0b06ce0bdc369429939c68e4d80b93e0fc777a3 100644 (file)
@@ -450,24 +450,23 @@ void Model_Update::updateArguments(FeaturePtr theFeature) {
   list<AttributePtr>::iterator aRefsIter = aRefs.begin();
   for (; aRefsIter != aRefs.end(); aRefsIter++) {
     std::shared_ptr<ModelAPI_AttributeSelection> aSel =
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*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<ModelAPI_AttributeSelection>(*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<ModelAPI_AttributeSelection> aSelAttr =
         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(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;
           }
         }
       }