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:
@@ -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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user