From 45232cd0fa81a377fef2bf13ecefd550949c4295 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 19 Feb 2017 20:36:40 +0100 Subject: [PATCH] fix crash in uIso of Sphere --- src/Mod/Part/App/GeometrySurfacePyImp.cpp | 10 +++++++ src/Mod/Part/App/SpherePyImp.cpp | 32 ++--------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/Mod/Part/App/GeometrySurfacePyImp.cpp b/src/Mod/Part/App/GeometrySurfacePyImp.cpp index e916db4653..95d36aae8e 100644 --- a/src/Mod/Part/App/GeometrySurfacePyImp.cpp +++ b/src/Mod/Part/App/GeometrySurfacePyImp.cpp @@ -279,6 +279,11 @@ PyObject* GeometrySurfacePy::uIso(PyObject * args) Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast (getGeometryPtr()->handle()); Handle_Geom_Curve c = surf->UIso(v); + if (c.IsNull()) { + PyErr_SetString(PyExc_RuntimeError, "failed to create u iso curve"); + return 0; + } + if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); GeomLine* line = new GeomLine(); @@ -308,6 +313,11 @@ PyObject* GeometrySurfacePy::vIso(PyObject * args) Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast (getGeometryPtr()->handle()); Handle_Geom_Curve c = surf->VIso(v); + if (c.IsNull()) { + PyErr_SetString(PyExc_RuntimeError, "failed to create v iso curve"); + return 0; + } + if (c->IsKind(STANDARD_TYPE(Geom_Line))) { Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c); GeomLine* line = new GeomLine(); diff --git a/src/Mod/Part/App/SpherePyImp.cpp b/src/Mod/Part/App/SpherePyImp.cpp index cdb3a24529..839a1abfb4 100644 --- a/src/Mod/Part/App/SpherePyImp.cpp +++ b/src/Mod/Part/App/SpherePyImp.cpp @@ -183,40 +183,12 @@ void SpherePy::setAxis(Py::Object arg) PyObject *SpherePy::uIso(PyObject *args) { - double v; - if (!PyArg_ParseTuple(args, "d", &v)) - return 0; - - try { - Handle_Geom_SphericalSurface sphere = Handle_Geom_SphericalSurface::DownCast - (getGeomSpherePtr()->handle()); - Handle_Geom_Curve c = sphere->UIso(v); - return new CirclePy(new GeomCircle(Handle_Geom_Circle::DownCast(c))); - } - catch (Standard_Failure) { - Handle_Standard_Failure e = Standard_Failure::Caught(); - PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); - return 0; - } + return GeometrySurfacePy::uIso(args); } PyObject *SpherePy::vIso(PyObject *args) { - double v; - if (!PyArg_ParseTuple(args, "d", &v)) - return 0; - - try { - Handle_Geom_SphericalSurface sphere = Handle_Geom_SphericalSurface::DownCast - (getGeomSpherePtr()->handle()); - Handle_Geom_Curve c = sphere->VIso(v); - return new CirclePy(new GeomCircle(Handle_Geom_Circle::DownCast(c))); - } - catch (Standard_Failure) { - Handle_Standard_Failure e = Standard_Failure::Caught(); - PyErr_SetString(PartExceptionOCCError, e->GetMessageString()); - return 0; - } + return GeometrySurfacePy::vIso(args); } PyObject *SpherePy::getCustomAttributes(const char* /*attr*/) const