Skip to content

Commit

Permalink
Py: fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 9, 2021
1 parent cc0af9b commit 4e4068e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/Mod/Part/App/TopoShapeFacePyImp.cpp
Expand Up @@ -977,13 +977,14 @@ Py::Object TopoShapeFacePy::getWire(void) const

Py::Object TopoShapeFacePy::getOuterWire(void) const
{
const TopoDS_Shape& clSh = getTopoShapePtr()->getShape();
if (clSh.IsNull())
const TopoDS_Shape& shape = getTopoShapePtr()->getShape();
if (shape.IsNull())
throw Py::RuntimeError("Null shape");
if (clSh.ShapeType() == TopAbs_FACE) {
TopoDS_Face clFace = (TopoDS_Face&)clSh;
TopoDS_Wire clWire = ShapeAnalysis::OuterWire(clFace);
return Py::Object(new TopoShapeWirePy(new TopoShape(clWire)),true);
if (shape.ShapeType() == TopAbs_FACE) {
TopoDS_Wire wire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
Base::PyObjectBase* wirepy = new TopoShapeWirePy(new TopoShape(wire));
wirepy->setNotTracking();
return Py::asObject(wirepy);
}
else {
throw Py::TypeError("Internal error, TopoDS_Shape is not a face!");
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/Part/App/TopoShapeVertexPyImp.cpp
Expand Up @@ -194,7 +194,9 @@ Py::Object TopoShapeVertexPy::getPoint(void) const
try {
const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->getShape());
gp_Pnt p = BRep_Tool::Pnt(v);
return Py::asObject(new Base::VectorPy(new Base::Vector3d(p.X(),p.Y(),p.Z())));
Base::PyObjectBase* pnt = new Base::VectorPy(new Base::Vector3d(p.X(),p.Y(),p.Z()));
pnt->setNotTracking();
return Py::asObject(pnt);
}
catch (Standard_Failure& e) {

Expand Down

0 comments on commit 4e4068e

Please sign in to comment.