[TD]prevent fail during document restore
This commit is contained in:
@@ -795,9 +795,14 @@ TopoDS_Wire DrawComplexSection::makeSectionLineWire()
|
||||
App::DocumentObject* toolObj = CuttingToolWireObject.getValue();
|
||||
DrawViewPart* baseDvp = dynamic_cast<DrawViewPart*>(BaseView.getValue());
|
||||
if (baseDvp) {
|
||||
TopoDS_Shape toolShape = Part::Feature::getShape(toolObj);
|
||||
if (toolShape.IsNull()) {
|
||||
// CuttingToolWireObject is likely still restoring and has no shape yet
|
||||
return {};
|
||||
}
|
||||
Base::Vector3d centroid = baseDvp->getCurrentCentroid();
|
||||
TopoDS_Shape sTrans =
|
||||
ShapeUtils::ShapeUtils::moveShape(Part::Feature::getShape(toolObj), centroid * -1.0);
|
||||
ShapeUtils::ShapeUtils::moveShape(toolShape, centroid * -1.0);
|
||||
TopoDS_Shape sScaled = ShapeUtils::scaleShape(sTrans, baseDvp->getScale());
|
||||
//we don't mirror the scaled shape here as it will be mirrored by the projection
|
||||
|
||||
|
||||
@@ -148,6 +148,19 @@ void QGIViewPart::updateView(bool update)
|
||||
|
||||
void QGIViewPart::draw()
|
||||
{
|
||||
auto viewPart(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
if (!viewPart) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto doc = viewPart->getDocument();
|
||||
if (!doc || doc->testStatus(App::Document::Status::Restoring)) {
|
||||
// if the document is still restoring, we may not have all the information
|
||||
// we need to draw the source objects, so we wait until restore is finished.
|
||||
// Base::Console().Message("QGIVP::draw - document is restoring, do not draw\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
@@ -697,6 +710,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection, bool b)
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
|
||||
TechDraw::DrawViewPart* viewPart = static_cast<TechDraw::DrawViewPart*>(getViewObject());
|
||||
if (!viewPart)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user