Fix various Py::Object leak

This commit is contained in:
Zheng, Lei
2019-10-08 09:19:17 +08:00
committed by wwmayer
parent e764e6fee3
commit 8426ebe2ba
24 changed files with 40 additions and 40 deletions

View File

@@ -1300,7 +1300,7 @@ Py::Tuple FemMeshPy::getGroups(void) const
Py::Object FemMeshPy::getVolume(void) const
{
return Py::Object(new Base::QuantityPy(new Base::Quantity(getFemMeshPtr()->getVolume())));
return Py::asObject(new Base::QuantityPy(new Base::Quantity(getFemMeshPtr()->getVolume())));
}

View File

@@ -425,7 +425,7 @@ PyObject* MeshPy::crossSections(PyObject *args)
for (MeshObject::TPolylines::const_iterator jt = it->begin(); jt != it->end(); ++jt) {
Py::List polyline;
for (std::vector<Base::Vector3f>::const_iterator kt = jt->begin(); kt != jt->end(); ++kt) {
polyline.append(Py::Object(new Base::VectorPy(*kt)));
polyline.append(Py::asObject(new Base::VectorPy(*kt)));
}
section.append(polyline);
}
@@ -1989,7 +1989,7 @@ Py::Tuple MeshPy::getTopology(void) const
Py::List vertex;
for (std::vector<Base::Vector3d>::const_iterator it = Points.begin();
it != Points.end(); ++it)
vertex.append(Py::Object(new Base::VectorPy(*it)));
vertex.append(Py::asObject(new Base::VectorPy(*it)));
tuple.setItem(0, vertex);
Py::List facet;
for (std::vector<Data::ComplexGeoData::Facet>::const_iterator

View File

@@ -2095,7 +2095,7 @@ private:
if(retType==0)
return sret;
return Py::TupleN(sret,Py::Object(new Base::MatrixPy(new Base::Matrix4D(mat))),
return Py::TupleN(sret,Py::asObject(new Base::MatrixPy(new Base::Matrix4D(mat))),
subObj?Py::Object(subObj->getPyObject(),true):Py::Object());
}

View File

@@ -466,7 +466,7 @@ PyObject* BSplineCurvePy::getPoles(PyObject * args)
gp_Pnt pnt = p(i);
Base::VectorPy* vec = new Base::VectorPy(Base::Vector3d(
pnt.X(), pnt.Y(), pnt.Z()));
poles.append(Py::Object(vec));
poles.append(Py::asObject(vec));
}
return Py::new_reference_to(poles);
}

View File

@@ -721,7 +721,7 @@ PyObject* BSplineSurfacePy::getPoles(PyObject *args)
Py::List row;
for (Standard_Integer j=p.LowerCol(); j<=p.UpperCol(); j++) {
const gp_Pnt& pole = p(i,j);
row.append(Py::Object(new Base::VectorPy(
row.append(Py::asObject(new Base::VectorPy(
Base::Vector3d(pole.X(),pole.Y(),pole.Z()))));
}
poles.append(row);

View File

@@ -233,7 +233,7 @@ PyObject* BezierCurvePy::getPoles(PyObject * args)
gp_Pnt pnt = p(i);
Base::VectorPy* vec = new Base::VectorPy(Base::Vector3d(
pnt.X(), pnt.Y(), pnt.Z()));
poles.append(Py::Object(vec));
poles.append(Py::asObject(vec));
}
return Py::new_reference_to(poles);
}

View File

@@ -510,7 +510,7 @@ PyObject* BezierSurfacePy::getPoles(PyObject *args)
Py::List row;
for (Standard_Integer j=p.LowerCol(); j<=p.UpperCol(); j++) {
const gp_Pnt& pole = p(i,j);
row.append(Py::Object(new Base::VectorPy(
row.append(Py::asObject(new Base::VectorPy(
Base::Vector3d(pole.X(),pole.Y(),pole.Z()))));
}
poles.append(row);

View File

@@ -769,7 +769,7 @@ PyObject* GeometryCurvePy::intersectCS(PyObject *args)
Py::List points;
for (int i = 1; i <= intersector.NbPoints(); i++) {
gp_Pnt p = intersector.Point(i);
points.append(Py::Object(new PointPy(new GeomPoint(Base::Vector3d(p.X(), p.Y(), p.Z())))));
points.append(Py::asObject(new PointPy(new GeomPoint(Base::Vector3d(p.X(), p.Y(), p.Z())))));
}
Py::List segments;
for (int i = 1; i <= intersector.NbSegments(); i++) {

View File

@@ -1920,7 +1920,7 @@ PyObject* TopoShapePy::tessellate(PyObject *args)
Py::List vertex;
for (std::vector<Base::Vector3d>::const_iterator it = Points.begin();
it != Points.end(); ++it)
vertex.append(Py::Object(new Base::VectorPy(*it)));
vertex.append(Py::asObject(new Base::VectorPy(*it)));
tuple.setItem(0, vertex);
Py::List facet;
for (std::vector<Data::ComplexGeoData::Facet>::const_iterator
@@ -2841,7 +2841,7 @@ Py::Object TopoShapePy::getLocation(void) const
mat[2][1] = trf.Value(3,2);
mat[2][2] = trf.Value(3,3);
mat[2][3] = trf.Value(3,4);
return Py::Object(new Base::MatrixPy(mat));
return Py::asObject(new Base::MatrixPy(mat));
}
void TopoShapePy::setLocation(Py::Object o)

View File

@@ -244,7 +244,7 @@ PyObject* CommandPy::setFromGCode(PyObject *args)
Py::Object CommandPy::getPlacement(void) const
{
return Py::Object(new Base::PlacementPy(new Base::Placement(getCommandPtr()->getPlacement())));
return Py::asObject(new Base::PlacementPy(new Base::Placement(getCommandPtr()->getPlacement())));
}
void CommandPy::setPlacement(Py::Object arg)

View File

@@ -90,7 +90,7 @@ Py::List PathPy::getCommands(void) const
{
Py::List list;
for(unsigned int i = 0; i < getToolpathPtr()->getSize(); i++)
list.append(Py::Object(new Path::CommandPy(new Path::Command(getToolpathPtr()->getCommand(i)))));
list.append(Py::asObject(new Path::CommandPy(new Path::Command(getToolpathPtr()->getCommand(i)))));
return list;
}

View File

@@ -237,7 +237,7 @@ Py::List PointsPy::getPoints(void) const
Py::List PointList;
const PointKernel* points = getPointKernelPtr();
for (PointKernel::const_point_iterator it = points->begin(); it != points->end(); ++it) {
PointList.append(Py::Object(new Base::VectorPy(*it)));
PointList.append(Py::asObject(new Base::VectorPy(*it)));
}
return PointList;
}

View File

@@ -140,7 +140,7 @@ void Robot6AxisPy::setAxis6(Py::Float arg)
Py::Object Robot6AxisPy::getTcp(void) const
{
return Py::Object(new Base::PlacementPy(new Base::Placement(getRobot6AxisPtr()->getTcp())));
return Py::asObject(new Base::PlacementPy(new Base::Placement(getRobot6AxisPtr()->getTcp())));
}
void Robot6AxisPy::setTcp(Py::Object value)

View File

@@ -154,7 +154,7 @@ Py::List TrajectoryPy::getWaypoints(void) const
{
Py::List list;
for(unsigned int i = 0; i < getTrajectoryPtr()->getSize(); i++)
list.append(Py::Object(new Robot::WaypointPy(new Robot::Waypoint(getTrajectoryPtr()->getWaypoint(i)))));
list.append(Py::asObject(new Robot::WaypointPy(new Robot::Waypoint(getTrajectoryPtr()->getWaypoint(i)))));
return list;
}

View File

@@ -200,7 +200,7 @@ Py::Tuple SketchPy::getGeometries(void) const
Py::Object SketchPy::getShape(void) const
{
return Py::Object(new TopoShapePy(new TopoShape(getSketchPtr()->toShape())));
return Py::asObject(new TopoShapePy(new TopoShape(getSketchPtr()->toShape())));
}