Py: fix memory leaks by incorrect use of PyList_Append

This commit is contained in:
wmayer
2020-12-13 16:30:04 +01:00
parent 512d5c6141
commit aec9d5f07a
11 changed files with 174 additions and 185 deletions

View File

@@ -197,7 +197,8 @@ private:
} else {
biggie = false;
}
PyObject* result = PyList_New(0);
Py::List result;
try {
EdgeWalker ew;
@@ -207,16 +208,18 @@ private:
std::vector<TopoDS_Wire> rw = ew.getResultNoDups();
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(rw,biggie); //false==>do not include biggest wires
for (auto& w:sortedWires) {
PyList_Append(result,new TopoShapeWirePy(new TopoShape(w)));
PyObject* wire = new TopoShapeWirePy(new TopoShape(w));
result.append(Py::asObject(wire));
}
} else {
}
else {
Base::Console().Warning("edgeWalker: input is not planar graph. Wire detection not done\n");
}
}
catch (Base::Exception &e) {
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
}
return Py::asObject(result);
return result;
}
Py::Object findOuterWire(const Py::Tuple& args)