]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix crash on constraints which use Projection feature
authorazv <azv@opencascade.com>
Wed, 4 May 2016 14:24:59 +0000 (17:24 +0300)
committerazv <azv@opencascade.com>
Wed, 4 May 2016 14:25:25 +0000 (17:25 +0300)
src/PartSet/PartSet_ResultSketchPrs.cpp
src/SketchPlugin/SketchPlugin_Projection.cpp

index 8769ea22fa39ebd04f4cb6caf9924ce37131d04a..d59619780139f74ec118fa62d7be50f22f06625f 100755 (executable)
@@ -292,7 +292,7 @@ void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& theResultShape,
           std::shared_ptr<GeomAPI_Shape> aGeomShape = aConstr->shape();
           if (aGeomShape.get()) {
             const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
-            if (aShape.ShapeType() != TopAbs_EDGE)
+            if (!aShape.IsNull() && aShape.ShapeType() != TopAbs_EDGE)
               anAuxiliaryResults.push_back(aConstr);
           }
         }
index 5cccf4c2bad3ed7b5be4c778e7eb6fe502da12a5..319f200cb3069c54aa30ec91c47907a27d60f2bf 100644 (file)
 
 static const double tolerance = 1.e-7;
 
+static std::shared_ptr<GeomAPI_Edge> emptyEdge()
+{
+  static std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge);
+  return anEdge;
+}
+
 SketchPlugin_Projection::SketchPlugin_Projection()
     : SketchPlugin_SketchEntity(),
       myIsComputing(false)
@@ -58,7 +64,7 @@ void SketchPlugin_Projection::execute()
 
   if (!lastResult().get() && aProjection->lastResult().get()) {
     ResultConstructionPtr aConstr = document()->createConstruction(data());
-    aConstr->setShape(aProjection->lastResult()->shape());
+    aConstr->setShape(emptyEdge());
     aConstr->setIsInHistory(false);
     aConstr->setDisplayed(false);
     setResult(aConstr);
@@ -196,7 +202,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID)
     selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->context()->shape());
 
     if (aResult) {
-      aResult->setShape(aProjection->lastResult()->shape());
+      aResult->setShape(emptyEdge());
       setResult(aResult);
       aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
     }