]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1156
authormpv <mpv@opencascade.com>
Tue, 22 Dec 2015 08:34:52 +0000 (11:34 +0300)
committermpv <mpv@opencascade.com>
Tue, 22 Dec 2015 08:34:52 +0000 (11:34 +0300)
src/Model/Model_Session.cpp

index 6b3194d5a08b73e3065f9495fdc9393646cd7933..4f95c72cc7cefdf0934e46a8ad4e3997730344b9 100644 (file)
@@ -406,10 +406,25 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
       std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleted =
         std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
       if (aDeleted && 
-          aDeleted->groups().find(ModelAPI_ResultPart::group()) != aDeleted->groups().end() &&
-          !ModelAPI_Tools::findPartResult(moduleDocument(), activeDocument()).get()) // another part may be disabled
+          aDeleted->groups().find(ModelAPI_ResultPart::group()) != aDeleted->groups().end())
       {
-        setActiveDocument(moduleDocument());
+         // check that the current feature of the session is still the active Part (even disabled)
+        bool aFound = false;
+        FeaturePtr aCurrentPart = moduleDocument()->currentFeature(true);
+        if (aCurrentPart.get()) {
+          const std::list<std::shared_ptr<ModelAPI_Result> >& aResList = aCurrentPart->results();
+          std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResList.begin();
+          for(; !aFound && aRes != aResList.end(); aRes++) {
+            ResultPartPtr aPRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aRes);
+            if (aPRes.get() && aPRes->isActivated() && aPRes->partDoc() == activeDocument()) {
+              aFound = true;
+
+            }
+          }
+        }
+        if (!aFound) { // if not, the part was removed, so activate the module document
+          setActiveDocument(moduleDocument());
+        }
       }
     }
   }