aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-03-19 10:30:29 +0100
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-05-09 11:32:52 +0000
commit43451e3bc17467593df64cb73ce8c0bf9e60045f (patch)
tree00f85921652ffcd15d1d7fb1be4b8519462364ac /sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
parent9dc1aa57dfbf9c684e5c75451dd028b88099c348 (diff)
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 <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/PySide2/QtCore/typesystem_core_common.xml')
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml42
1 files changed, 21 insertions, 21 deletions
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 @@
<object-type name="QSocketNotifier">
<enum-type name="Type"/>
- <add-function signature="QSocketNotifier(PyObject*,QSocketNotifier::Type,QObject*)">
- <modify-argument index="3">
- <replace-default-expression with="0" />
- <rename to="parent" />
- </modify-argument>
- <inject-code>
- 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);
- }
- }
- </inject-code>
+ <add-function signature="QSocketNotifier(PyObject*, QSocketNotifier::Type, QObject*)">
+ <modify-argument index="3">
+ <replace-default-expression with="0" />
+ <rename to="parent" />
+ </modify-argument>
+ <inject-code>
+ 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.");
+ }
+ }
+ </inject-code>
</add-function>
</object-type>