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 02a8af773f
commit b3cd06afe8
11 changed files with 174 additions and 185 deletions

View File

@@ -76,10 +76,10 @@ PyObject* DrawViewDimensionPy::getLinearPoints(PyObject* args)
(void) args;
DrawViewDimension* dvd = getDrawViewDimensionPtr();
pointPair pts = dvd->getLinearPoints();
PyObject* ret = PyList_New(0);
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.first)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.second)));
return ret;
Py::List ret;
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.first))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.second))));
return Py::new_reference_to(ret);
}
PyObject* DrawViewDimensionPy::getArcPoints(PyObject* args)
@@ -87,14 +87,14 @@ PyObject* DrawViewDimensionPy::getArcPoints(PyObject* args)
(void) args;
DrawViewDimension* dvd = getDrawViewDimensionPtr();
arcPoints pts = dvd->getArcPoints();
PyObject* ret = PyList_New(0);
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.center)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.onCurve.first)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.onCurve.second)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.arcEnds.first)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.arcEnds.second)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.midArc)));
return ret;
Py::List ret;
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.center))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.onCurve.first))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.onCurve.second))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.arcEnds.first))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.arcEnds.second))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.midArc))));
return Py::new_reference_to(ret);
}
PyObject* DrawViewDimensionPy::getAnglePoints(PyObject* args)
@@ -102,11 +102,11 @@ PyObject* DrawViewDimensionPy::getAnglePoints(PyObject* args)
(void) args;
DrawViewDimension* dvd = getDrawViewDimensionPtr();
anglePoints pts = dvd->getAnglePoints();
PyObject* ret = PyList_New(0);
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.ends.first)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.ends.second)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.vertex)));
return ret;
Py::List ret;
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.ends.first))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.ends.second))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.vertex))));
return Py::new_reference_to(ret);
}
PyObject* DrawViewDimensionPy::getArrowPositions(PyObject* args)
@@ -114,10 +114,10 @@ PyObject* DrawViewDimensionPy::getArrowPositions(PyObject* args)
(void) args;
DrawViewDimension* dvd = getDrawViewDimensionPtr();
pointPair pts = dvd->getArrowPositions();
PyObject* ret = PyList_New(0);
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.first)));
PyList_Append(ret,new Base::VectorPy(new Base::Vector3d(pts.second)));
return ret;
Py::List ret;
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.first))));
ret.append(Py::asObject(new Base::VectorPy(new Base::Vector3d(pts.second))));
return Py::new_reference_to(ret);
}
PyObject *DrawViewDimensionPy::getCustomAttributes(const char* /*attr*/) const
{