From: azv Date: Wed, 4 May 2016 14:24:59 +0000 (+0300) Subject: Fix crash on constraints which use Projection feature X-Git-Tag: V_2.3.0~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=152a49556bb45dbe2a979fc055c7f501c52a8125;p=modules%2Fshaper.git Fix crash on constraints which use Projection feature --- diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index 8769ea22f..d59619780 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -292,7 +292,7 @@ void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& theResultShape, std::shared_ptr aGeomShape = aConstr->shape(); if (aGeomShape.get()) { const TopoDS_Shape& aShape = aGeomShape->impl(); - if (aShape.ShapeType() != TopAbs_EDGE) + if (!aShape.IsNull() && aShape.ShapeType() != TopAbs_EDGE) anAuxiliaryResults.push_back(aConstr); } } diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 5cccf4c2b..319f200cb 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -31,6 +31,12 @@ static const double tolerance = 1.e-7; +static std::shared_ptr emptyEdge() +{ + static std::shared_ptr 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()); }