[TD]prevent crash when no event loop
- threaded hlr operations do not return if qApplication is not available
This commit is contained in:
@@ -43,6 +43,9 @@
|
||||
#include <Base/PyWrapParseTupleAndKeywords.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
|
||||
#include <Mod/Import/App/dxf/ImpExpDxf.h>
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
@@ -434,6 +437,10 @@ private:
|
||||
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
|
||||
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
|
||||
TechDraw::GeometryObjectPtr gObj = dvp->getGeometryObject();
|
||||
if (!gObj) {
|
||||
Base::Console().Message("TechDraw: %s has no geometry object!\n", dvp->Label.getValue());
|
||||
return Py::String();
|
||||
}
|
||||
TopoDS_Shape shape = ShapeUtils::mirrorShape(gObj->getVisHard());
|
||||
ss << dxfOut.exportEdges(shape);
|
||||
shape = ShapeUtils::mirrorShape(gObj->getVisOutline());
|
||||
@@ -472,6 +479,7 @@ private:
|
||||
return dxfReturn;
|
||||
}
|
||||
|
||||
|
||||
Py::Object viewPartAsSvg(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *viewObj(nullptr);
|
||||
@@ -482,6 +490,7 @@ private:
|
||||
std::string grpHead1 = "<g fill=\"none\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"";
|
||||
std::string grpHead2 = "\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-miterlimit=\"4\">\n";
|
||||
std::string grpTail = "</g>\n";
|
||||
Base::Console().Message("TechDraw:: gui is up? %d\n", (int)DrawUtil::isGuiUp());
|
||||
try {
|
||||
App::DocumentObject* obj = nullptr;
|
||||
TechDraw::DrawViewPart* dvp = nullptr;
|
||||
@@ -492,9 +501,13 @@ private:
|
||||
obj = static_cast<App::DocumentObjectPy*>(viewObj)->getDocumentObjectPtr();
|
||||
dvp = static_cast<TechDraw::DrawViewPart*>(obj);
|
||||
TechDraw::GeometryObjectPtr gObj = dvp->getGeometryObject();
|
||||
if (!gObj) {
|
||||
Base::Console().Message("TechDraw: %s has no geometry object!\n", dvp->Label.getValue());
|
||||
return Py::String();
|
||||
}
|
||||
|
||||
//visible group begin "<g ... >"
|
||||
ss << grpHead1;
|
||||
// double thick = dvp->LineWidth.getValue();
|
||||
double thick = DrawUtil::getDefaultLineWeight("Thick");
|
||||
ss << thick;
|
||||
ss << grpHead2;
|
||||
@@ -518,7 +531,6 @@ private:
|
||||
dvp->SeamHidden.getValue() ) {
|
||||
//hidden group begin
|
||||
ss << grpHead1;
|
||||
// thick = dvp->HiddenWidth.getValue();
|
||||
thick = DrawUtil::getDefaultLineWeight("Thin");
|
||||
ss << thick;
|
||||
ss << grpHead2;
|
||||
@@ -553,9 +565,16 @@ private:
|
||||
|
||||
void write1ViewDxf( ImpExpDxfWrite& writer, TechDraw::DrawViewPart* dvp, bool alignPage)
|
||||
{
|
||||
if(!dvp->hasGeometry())
|
||||
if(!dvp->hasGeometry()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::GeometryObjectPtr gObj = dvp->getGeometryObject();
|
||||
if (!gObj) {
|
||||
// this test might be redundent here since we already checked hasGeometry.
|
||||
Base::Console().Message("TechDraw: %s has no geometry object!\n", dvp->Label.getValue());
|
||||
return;
|
||||
}
|
||||
TopoDS_Shape shape = ShapeUtils::mirrorShape(gObj->getVisHard());
|
||||
double offX = 0.0;
|
||||
double offY = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user