Skip to content

Commit

Permalink
Gui: PythonWrapper: Do not steal reference
Browse files Browse the repository at this point in the history
Foreign Python objects needs to be passed as Py::Object().
Py::asObject() is stealing reference and object might be garbage
collected even before dereferenced. Problem didn't show in the
original code because methods Py::asObject() was used in were
never called.

Fixes: ac6f991 (Gui: Consolidate Python -> Qt class conversion)
  • Loading branch information
3x380V authored and wwmayer committed Feb 24, 2024
1 parent 8a3407a commit 967633e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Gui/PythonWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ qttype* qt_getCppType(PyObject* pyobj)
Py::Callable func = mainmod.getDict().getItem("getCppPointer");

Py::Tuple arguments(1);
arguments[0] = Py::asObject(pyobj); // PySide pointer
arguments[0] = Py::Object(pyobj); // PySide pointer
Py::Tuple result(func.apply(arguments));
return reinterpret_cast<qttype*>(PyLong_AsVoidPtr(result[0].ptr()));
}
Expand Down

0 comments on commit 967633e

Please sign in to comment.