From 6554f407beaaa988a1d59eb7eee4766376bad18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Tue, 26 Nov 2019 19:19:05 +0100 Subject: Fix refcount issues with QSettings glue code Task-number: PYSIDE-939 Change-Id: I5bda4e2025e31bf192bf0bf70c82aa626cd19714 Reviewed-by: Christian Tismer --- sources/pyside2/PySide2/glue/qtcore.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sources') diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index 47b3dd6db..8bcc315b2 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -81,7 +81,6 @@ if (typeObj) { for (int i = 0; i < valuesSize; i++) { PyObject *item = PyUnicode_FromString(valuesList[i].data()); PyList_SET_ITEM(list, i, item); - Py_DECREF(item); } %PYARG_0 = list; @@ -110,15 +109,23 @@ if (typeObj) { float asFloat = out.toFloat(); %PYARG_0 = PyFloat_FromDouble(asFloat); } else if (typeObj == &PyBool_Type) { - %PYARG_0 = out.toBool() ? Py_True : Py_False; + if (out.toBool()) { + Py_INCREF(Py_True); + %PYARG_0 = Py_True; + } else { + Py_INCREF(Py_False); + %PYARG_0 = Py_False; + } } // TODO: PyDict_Type and PyTuple_Type } else { - if (!out.isValid()) + if (!out.isValid()) { + Py_INCREF(Py_None); %PYARG_0 = Py_None; - else + } else { %PYARG_0 = %CONVERTTOPYTHON[QVariant](out); + } } // @snippet qsettings-value -- cgit v1.2.3