From 72d591a0eded88a734573f679643400a5ed78fa9 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 24 Jun 2015 08:01:48 +0300 Subject: [PATCH] Issue #672 - Crash when distance constraint reason: an empty shape if the selected shape is equal to the shape of result --- src/PartSet/PartSet_WidgetMultiSelector.cpp | 20 ++++++++++++++------ src/PartSet/PartSet_WidgetShapeSelector.cpp | 14 +++++++++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index d6c000897..60b2573e7 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -99,11 +99,19 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& t std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aSelectedFeature); // there is no a sketch feature is selected, but the shape exists, try to create an exernal object - if (aSPFeature.get() == NULL && theShape.get() != NULL && !theShape->isNull() && - myExternalObjectMgr->useExternal()) { - if (myIsInVaildate) - theObject = myExternalObjectMgr->externalObjectValidated(theObject, theShape, sketch()); - else - theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch()); + // TODO: unite with the same functionality in PartSet_WidgetShapeSelector + if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) { + GeomShapePtr aShape = theShape; + if (!aShape.get()) { + ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + if (aResult.get()) + aShape = aResult->shape(); + } + if (aShape.get() != NULL && !aShape->isNull()) { + if (myIsInVaildate) + theObject = myExternalObjectMgr->externalObjectValidated(theObject, theShape, sketch()); + else + theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch()); + } } } diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 7fca13598..431f1e8a8 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -77,9 +77,17 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aSelectedFeature); // there is no a sketch feature is selected, but the shape exists, try to create an exernal object - if (aSPFeature.get() == NULL && theShape.get() != NULL && !theShape->isNull() && - myExternalObjectMgr->useExternal()) - theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch()); + // TODO: unite with the same functionality in PartSet_WidgetShapeSelector + if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) { + GeomShapePtr aShape = theShape; + if (!aShape.get()) { + ResultPtr aResult = myWorkshop->selection()->getResult(thePrs); + if (aResult.get()) + aShape = aResult->shape(); + } + if (aShape.get() != NULL && !aShape->isNull()) + theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch()); + } } //******************************************************************** -- 2.30.2