From: mpv Date: Mon, 7 Sep 2015 15:08:27 +0000 (+0300) Subject: Fix for crash on SALOME-aplpication with sub-part close. X-Git-Tag: V_1.4.0_beta4~85 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a57d0b737f2b753efe5195e0ac88d9ebbe92d651;p=modules%2Fshaper.git Fix for crash on SALOME-aplpication with sub-part close. --- diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 1da66a845..56c2a0fe6 100755 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -160,11 +160,13 @@ void findRandomColor(std::vector& 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( - 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( + theMain->object(ModelAPI_ResultPart::group(), a)); + if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == theSub) { + return aPart; + } } } return ResultPtr();