Skip to content

Commit 003b720

Browse files
msmolensjcfr
authored andcommitted
Fix refcount of PyInt_Type when creating enum wrapper
This commit increments the refcount of the built-in PyInt_Type instance when creating an enum wrapper. This is necessary because PyTuple_SET_ITEM steals a reference to that instance. Fixing the refcount prevents a crash when calling Py_Finalize().
1 parent 54d0e9d commit 003b720

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/PythonQt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ PyObject* PythonQtPrivate::createNewPythonQtEnumWrapper(const char* enumName, Py
693693
PyObject* className = PyString_FromString(enumName);
694694

695695
PyObject* baseClasses = PyTuple_New(1);
696+
Py_INCREF(&PyInt_Type);
696697
PyTuple_SET_ITEM(baseClasses, 0, (PyObject*)&PyInt_Type);
697698

698699
PyObject* module = PyObject_GetAttrString(parentObject, "__module__");

0 commit comments

Comments
 (0)