From 43451e3bc17467593df64cb73ce8c0bf9e60045f Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 19 Mar 2018 10:30:29 +0100 Subject: Fix QSocketNotifier constructor The first argument was modified to be a socket type, but it needs to be an int (file descriptor). Adding a new signature solves the compatibility problem between Python2 and 3. A test case was added. Task-number: PYSIDE-629 Change-Id: Id9dea37459350dfc90d0f0ab9e2e1993d03fe6e4 Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint Reviewed-by: Christian Tismer --- .../PySide2/QtCore/typesystem_core_common.xml | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index 403166d4a..f8259063d 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -2994,27 +2994,27 @@ - - - - - - - Shiboken::AutoDecRef fileNo(PyObject_GetAttrString(%PYARG_1, "fileno")); - if (!fileNo.isNull()) { - Shiboken::AutoDecRef fileNoValue(PyObject_CallObject(fileNo, 0)); - if (%CHECKTYPE[int](fileNoValue)) { - int cppFileNoValue = %CONVERTTOCPP[int](fileNoValue); - /* Qt4 version: - * %0 = new %TYPE(cppFileNoValue, %2, %3); - * Qt5 has qintptr instead. - * XXX check if this means a pointer or just the pointer size cast (what I implemented) - */ - qintptr socket = (qintptr)cppFileNoValue; - %0 = new %TYPE(socket, %2, %3); - } - } - + + + + + + + Shiboken::AutoDecRef socket(%PYARG_1); + if (!socket.isNull()) { + // We use qintptr as PyLong, but we check for int + // since it is currently an alias to be Python2 compatible. + // Internally, ints are qlonglongs. + if (%CHECKTYPE[int](socket)) { + int cppSocket = %CONVERTTOCPP[int](socket); + qintptr socket = (qintptr)cppSocket; + %0 = new %TYPE(socket, %2, %3); + } else { + PyErr_SetString(PyExc_TypeError, + "QSocketNotifier: first argument (socket) must be an int."); + } + } + -- cgit v1.2.3