]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_WidgetShapeSelector.cpp
Salome HOME
Issue #672 - Crash when distance constraint
[modules/shaper.git] / src / PartSet / PartSet_WidgetShapeSelector.cpp
index 7fca13598405600bfe582cdbd24d256429bbcc71..431f1e8a88db447743c393aaff943f3778878684 100644 (file)
@@ -77,9 +77,17 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
           std::dynamic_pointer_cast<SketchPlugin_Feature>(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());
+  }
 }
 
 //********************************************************************