Part: geometry extensions several memory leak fixes

This commit is contained in:
Abdullah Tahiri
2019-02-12 19:36:50 +01:00
committed by wmayer
parent 21e1ccbe9b
commit 4d86374cb0
2 changed files with 10 additions and 6 deletions

View File

@@ -72,7 +72,7 @@ PyObject* GeometryExtensionPy::copy(PyObject *args)
Part::GeometryExtension* clone = static_cast<Part::GeometryExtension*>(extpy->_pcTwinPointer);
delete clone;
}
extpy->_pcTwinPointer = ext->copy().get();
extpy->_pcTwinPointer = ext->copy().release();
return cpy;
}

View File

@@ -270,9 +270,9 @@ PyObject* GeometryPy::getExtensionOfType(PyObject *args)
std::shared_ptr<GeometryExtension> ext(this->getGeometryPtr()->getExtension(type));
// we create a copy and tranfer this copy's memory management responsibility to Python
GeometryExtension * rext = ext->copy().release();
PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
return rext->getPyObject();
return cpy;
}
catch(Base::ValueError e) {
PyErr_SetString(PartExceptionOCCError, e.what());
@@ -304,9 +304,9 @@ PyObject* GeometryPy::getExtensionOfName(PyObject *args)
std::shared_ptr<GeometryExtension> ext(this->getGeometryPtr()->getExtension(std::string(o)));
// we create a copy and tranfer this copy's memory management responsibility to Python
GeometryExtension * rext = ext->copy().release();
PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
return rext->getPyObject();
return cpy;
}
catch(Base::ValueError e) {
PyErr_SetString(PartExceptionOCCError, e.what());
@@ -437,7 +437,11 @@ PyObject* GeometryPy::getExtensions(PyObject *args)
std::shared_ptr<GeometryExtension> p = ext[i].lock();
if(p) {
PyList_SetItem( list, i, p->getPyObject());
// we create a python copy and add it to the list
Py::Tuple args(size_t(0));
PyObject* cpy = static_cast<GeometryExtensionPy *>(p->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
PyList_SetItem( list, i, cpy);
}
}