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.
// make a visible circle
std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
- bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
- if (aHasPlane) {
- std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
- // compute the circle radius
- double aRadius = aRadiusAttr->value();
-
- std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(
- aCenter, aNormal, aRadius);
- aShapes.push_back(aCircleShape);
- std::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
- data(), 1);
- aConstr2->setShape(aCircleShape);
- aConstr2->setIsInHistory(false);
- setResult(aConstr2, 1);
- }
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
+ // compute the circle radius
+ double aRadius = aRadiusAttr->value();
+
+ std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(
+ aCenter, aNormal, aRadius);
+ aShapes.push_back(aCircleShape);
+ std::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
+ data(), 1);
+ aConstr2->setShape(aCircleShape);
+ aConstr2->setIsInHistory(false);
+ setResult(aConstr2, 1);
}
}
}
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);
}
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);
}