diff --git a/src/Mod/Part/App/GeometryExtensionPyImp.cpp b/src/Mod/Part/App/GeometryExtensionPyImp.cpp index 28a63ebbbc..36304950fe 100644 --- a/src/Mod/Part/App/GeometryExtensionPyImp.cpp +++ b/src/Mod/Part/App/GeometryExtensionPyImp.cpp @@ -72,7 +72,7 @@ PyObject* GeometryExtensionPy::copy(PyObject *args) Part::GeometryExtension* clone = static_cast(extpy->_pcTwinPointer); delete clone; } - extpy->_pcTwinPointer = ext->copy().get(); + extpy->_pcTwinPointer = ext->copy().release(); return cpy; } diff --git a/src/Mod/Part/App/GeometryPyImp.cpp b/src/Mod/Part/App/GeometryPyImp.cpp index a7e93de9b3..5fd1aa6376 100644 --- a/src/Mod/Part/App/GeometryPyImp.cpp +++ b/src/Mod/Part/App/GeometryPyImp.cpp @@ -270,9 +270,9 @@ PyObject* GeometryPy::getExtensionOfType(PyObject *args) std::shared_ptr 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(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 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(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 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(p->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0)))); + + PyList_SetItem( list, i, cpy); } }