From 3fd1827084c1119a3f6be77eb61f03af54001447 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 2 Jan 2012 14:03:55 +0000 Subject: [PATCH] + check for null shape before calling BRep_Tool::IsClosed git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5379 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 4 +++- src/Mod/Part/App/TopoShapePyImp.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index ad7791ede..b69049e6e 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -123,7 +123,7 @@ int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) { TopoShape* shape = static_cast(pcObj)->getTopoShapePtr(); - if (shape && shape->_Shape.ShapeType() == TopAbs_EDGE) { + if (shape && !shape->_Shape.IsNull() && shape->_Shape.ShapeType() == TopAbs_EDGE) { this->getTopoShapePtr()->_Shape = shape->_Shape; return 0; } @@ -507,6 +507,8 @@ Py::Object TopoShapeEdgePy::getCenterOfMass(void) const Py::Boolean TopoShapeEdgePy::getClosed(void) const { + if (getTopoShapePtr()->_Shape.IsNull()) + throw Py::Exception("Cannot determine the 'Closed'' flag of an empty shape"); Standard_Boolean ok = BRep_Tool::IsClosed(getTopoShapePtr()->_Shape); return Py::Boolean(ok ? true : false); } diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 37b7c18b8..598e7ad8b 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1030,6 +1030,8 @@ PyObject* TopoShapePy::isClosed(PyObject *args) if (!PyArg_ParseTuple(args, "")) return NULL; try { + if (getTopoShapePtr()->_Shape.IsNull()) + Standard_Failure::Raise("Cannot determine the 'Closed'' flag of an empty shape"); return Py_BuildValue("O", (getTopoShapePtr()->isClosed() ? Py_True : Py_False)); } catch (...) {