From 71253bad8169ad3762824c8006208548879b6245 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sat, 23 Dec 2017 13:56:00 -0500 Subject: [PATCH] Fix crash when Source.Shape is Null --- src/Mod/TechDraw/App/DrawViewPart.cpp | 36 +++++++++++++----------- src/Mod/TechDraw/App/DrawViewSection.cpp | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 223ec94a02..9055c9da62 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -238,20 +238,22 @@ TopoDS_Shape DrawViewPart::getShapeFromPart(App::Part* ap) const TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const { TopoDS_Shape baseShape = getSourceShape(); - TopoDS_Iterator it(baseShape); - TopoDS_Shape fusedShape = it.Value(); - it.Next(); - for (; it.More(); it.Next()) { - const TopoDS_Shape& aChild = it.Value(); - BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild); - // Let's check if the fusion has been successful - if (!mkFuse.IsDone()) { - Base::Console().Error("DVp - Fusion failed\n"); - return baseShape; + if (!baseShape.IsNull()) { + TopoDS_Iterator it(baseShape); + TopoDS_Shape fusedShape = it.Value(); + it.Next(); + for (; it.More(); it.Next()) { + const TopoDS_Shape& aChild = it.Value(); + BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild); + // Let's check if the fusion has been successful + if (!mkFuse.IsDone()) { + Base::Console().Error("DVp - Fusion failed\n"); + return baseShape; + } + fusedShape = mkFuse.Shape(); } - fusedShape = mkFuse.Shape(); + baseShape = fusedShape; } - baseShape = fusedShape; return baseShape; } @@ -795,10 +797,12 @@ void DrawViewPart::unsetupObject() std::vector dims = getDimensions(); std::vector::iterator it3 = dims.begin(); for (; it3 != dims.end(); it3++) { - page->removeView(*it3); - std::string viewName = (*it3)->getNameInDocument(); - Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")", - docName.c_str(), viewName.c_str()); + page->removeView(*it3); + const char* name = (*it3)->getNameInDocument(); + if (name) { + Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")", + docName.c_str(), name); + } } } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 40b1bba132..86d1a4ce17 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -202,6 +202,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) TopoDS_Shape baseShape = static_cast(base)->getSourceShapeFused(); if (baseShape.IsNull()) { Base::Console().Log("DVS::execute - baseShape is Null\n"); + return new App::DocumentObjectExecReturn("BaseView Source object is Null"); } //is SectionOrigin valid?