Skip to content

Commit

Permalink
fix crash with Py3 when releasing memory buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 27, 2018
1 parent 3b1e1f8 commit b6712e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App/Document.cpp
Expand Up @@ -1293,6 +1293,7 @@ Document::~Document()
// not to dec'ref the Python object any more.
// But we must still invalidate the Python object because it doesn't need to be
// destructed right now because the interpreter can own several references to it.
Base::PyGILStateLocker lock;
Base::PyObjectBase* doc = (Base::PyObjectBase*)DocumentPythonObject.ptr();
// Call before decrementing the reference counter, otherwise a heap error can occur
doc->setInvalid();
Expand Down
1 change: 1 addition & 0 deletions src/App/DocumentObject.cpp
Expand Up @@ -63,6 +63,7 @@ DocumentObject::DocumentObject(void)
DocumentObject::~DocumentObject(void)
{
if (!PythonObject.is(Py::_None())){
Base::PyGILStateLocker lock;
// Remark: The API of Py::Object has been changed to set whether the wrapper owns the passed
// Python object or not. In the constructor we forced the wrapper to own the object so we need
// not to dec'ref the Python object any more.
Expand Down

0 comments on commit b6712e2

Please sign in to comment.