From 6108df521065e3a4628ae5656c3cbfd281b6765d Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 9 Jun 2019 17:13:28 +0200 Subject: Fix negative refcount on QSocketNotifier Change 43451e3bc17467593df64cb73ce8c0bf9e60045f from 2018-05-09 introduced a refcount bug that was not caught because we do not build with debug Python. This also revealed an omission in the patch "PySide: Allow any existing attribute in the constructor" when debug Python is used. Change-Id: Idbcbbc87f0a83bb696d03e05af0cf616b21f7335 Fixes: PYSIDE-1027 Reviewed-by: Friedemann Kleint Reviewed-by: Cristian Maureira-Fredes --- sources/pyside2/PySide2/glue/qtcore.cpp | 4 ++-- sources/pyside2/libpyside/pyside.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index fde016548..f30607f6b 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -1211,8 +1211,8 @@ QByteArray ba(1 + int(%2), char(0)); // @snippet qcryptographichash-adddata // @snippet qsocketnotifier -Shiboken::AutoDecRef socket(%PYARG_1); -if (!socket.isNull()) { +PyObject *socket = %PYARG_1; +if (socket != nullptr) { // We use qintptr as PyLong, but we check for int // since it is currently an alias to be Python2 compatible. // Internally, ints are qlonglongs. diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index 170a3587f..fff28a9e7 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -108,6 +108,7 @@ static bool _setProperty(PyObject* qObj, PyObject *name, PyObject *value, bool * if (retval.isNull()) return false; } else { + PyErr_Clear(); Shiboken::AutoDecRef attr(PyObject_GenericGetAttr(qObj, name)); if (PySide::Property::checkType(attr)) { *accept = true; -- cgit v1.2.3