From: nds Date: Thu, 28 May 2015 15:59:09 +0000 (+0300) Subject: Temporary fix, which will be corrected by MPV. Crash fix: Create circle, translation... X-Git-Tag: V_1.2.0~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=79b1a844d2efcc1b4c7acf43c27c97aa3accd8da;p=modules%2Fshaper.git Temporary fix, which will be corrected by MPV. Crash fix: Create circle, translation, Undo, Redo. The reason is that SketchPlugin_Circle::execute() flushes redisplay on 1st result creation. SketcerPrs listen it and obtains all results in the references list. The 2nd result is not created yet and it leads to crash. --- diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index 8625d578b..1b74f50ee 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -55,22 +55,19 @@ void SketchPlugin_Circle::execute() // make a visible circle std::shared_ptr aNDir = std::dynamic_pointer_cast( - aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); - bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); - if (aHasPlane) { - std::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); - // compute the circle radius - double aRadius = aRadiusAttr->value(); - - std::shared_ptr aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle( - aCenter, aNormal, aRadius); - aShapes.push_back(aCircleShape); - std::shared_ptr aConstr2 = document()->createConstruction( - data(), 1); - aConstr2->setShape(aCircleShape); - aConstr2->setIsInHistory(false); - setResult(aConstr2, 1); - } + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); + // compute the circle radius + double aRadius = aRadiusAttr->value(); + + std::shared_ptr aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle( + aCenter, aNormal, aRadius); + aShapes.push_back(aCircleShape); + std::shared_ptr aConstr2 = document()->createConstruction( + data(), 1); + aConstr2->setShape(aCircleShape); + aConstr2->setIsInHistory(false); + setResult(aConstr2, 1); } } } diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp index 2c680a64a..dca445bfd 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.cpp +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -52,11 +52,23 @@ bool SketcherPrs_Mirror::updatePoints(double theStep) const gp_Pnt aP1; for (i = 0; i < aNb; i++) { aObj = anAttrB->object(i); + if (!aObj.get()) // TODO:empty_result + // this check should be removed here after the result flush is corrected + // the problem is, that feature::execute() flushes redisplay by each result creation + // but it is possible(e.g. in the sketch circle, that there should be more than one result. + // Here, crash happens, because the second result is not created yet + continue; aP1 = aMgr->getPosition(aObj, this, theStep); myPntArray->SetVertice(i + 1, aP1); } for (i = 0; i < aNb; i++) { aObj = anAttrC->object(i); + if (!aObj.get()) // TODO:empty_result + // this check should be removed here after the result flush is corrected + // the problem is, that feature::execute() flushes redisplay by each result creation + // but it is possible(e.g. in the sketch circle, that there should be more than one result. + // Here, crash happens, because the second result is not created yet + continue; aP1 = aMgr->getPosition(aObj, this, theStep); myPntArray->SetVertice(aNb + i + 1, aP1); } diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp index dcbe96667..47f32f7b5 100644 --- a/src/SketcherPrs/SketcherPrs_Transformation.cpp +++ b/src/SketcherPrs/SketcherPrs_Transformation.cpp @@ -47,6 +47,12 @@ bool SketcherPrs_Transformation::updatePoints(double theStep) const gp_Pnt aP1; for (i = 0; i < aNbB; i++) { aObj = anAttrB->object(i); + if (!aObj.get()) // TODO:empty_result + // this check should be removed here after the result flush is corrected + // the problem is, that feature::execute() flushes redisplay by each result creation + // but it is possible(e.g. in the sketch circle, that there should be more than one result. + // Here, crash happens, because the second result is not created yet + continue; aP1 = aMgr->getPosition(aObj, this, theStep); myPntArray->SetVertice(i + 1, aP1); }