]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for crash on SALOME-aplpication with sub-part close.
authormpv <mpv@opencascade.com>
Mon, 7 Sep 2015 15:08:27 +0000 (18:08 +0300)
committermpv <mpv@opencascade.com>
Mon, 7 Sep 2015 15:08:27 +0000 (18:08 +0300)
src/ModelAPI/ModelAPI_Tools.cpp

index 1da66a8455a1ddf10bca590fe54e44bc74601bc2..56c2a0fe63e6aafcd1788b030e76ed4139765699 100755 (executable)
@@ -160,11 +160,13 @@ void findRandomColor(std::vector<int>& theValues)
 
 ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub)
 {
-  for (int a = theMain->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
-    ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(
-        theMain->object(ModelAPI_ResultPart::group(), a));
-    if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == theSub) {
-      return aPart;
+  if (theMain != theSub) { // to optimize and avoid of crash on partset document close (don't touch the sub-document structure)
+    for (int a = theMain->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
+      ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(
+          theMain->object(ModelAPI_ResultPart::group(), a));
+      if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == theSub) {
+        return aPart;
+      }
     }
   }
   return ResultPtr();