Gui: PythonWrapper: Do not steal reference

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: 26babf4d3674 (Gui: Consolidate Python -> Qt class conversion)
This commit is contained in:
Ladislav Michl
2024-02-24 00:18:31 +01:00
committed by wwmayer
parent c3fe250be9
commit 282c44ead1

View File

@@ -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()));
}