diff options
author | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2018-01-29 15:09:03 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-02-01 06:48:01 +0000 |
commit | 71aa687341b8f4c0ad927b4d9fc60a1aaab6eab3 (patch) | |
tree | 5bf3b066122180ec4a1191ce0908526b4276137a /sources | |
parent | cc9950a7dc15c533529b34f1b6b9737c7c19fec0 (diff) |
Fix error with second Qt.UniqueConnection call
The current implementation was considering only Py_True
as a success, but not Py_False.
The else statement will enter just in case of error,
as intended.
Added a test case to verify the proper behavior of
Qt.UniqueConnection.
Task-number: PYSIDE-34
Change-Id: I5bafe0e81383022dcd7fc6251fc61d0ab5e918d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/libpyside/pysidesignal.cpp | 2 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/qobject_test.py | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp index e213ff069..9f60d2a41 100644 --- a/sources/pyside2/libpyside/pysidesignal.cpp +++ b/sources/pyside2/libpyside/pysidesignal.cpp @@ -433,7 +433,7 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds) return 0; } PyObject* result = PyObject_CallObject(pyMethod, tupleArgs); - if (result == Py_True) + if (result == Py_True || result == Py_False) return result; else Py_XDECREF(result); diff --git a/sources/pyside2/tests/QtCore/qobject_test.py b/sources/pyside2/tests/QtCore/qobject_test.py index 482ae78be..bafa8a643 100644 --- a/sources/pyside2/tests/QtCore/qobject_test.py +++ b/sources/pyside2/tests/QtCore/qobject_test.py @@ -34,7 +34,12 @@ import unittest import py3kcompat as py3k -from PySide2.QtCore import QObject +from PySide2.QtCore import QObject, Signal, Qt + +class Obj(QObject): + signal = Signal() + def empty(self): + pass class ObjectNameCase(unittest.TestCase): '''Tests related to QObject object name''' @@ -67,6 +72,12 @@ class ObjectNameCase(unittest.TestCase): obj.setObjectName(name) self.assertEqual(obj.objectName(), name) + def testUniqueConnection(self): + obj = Obj() + # On first connect, UniqueConnection returns True, and on the second + # it must return False, and not a RuntimeError (PYSIDE-34) + self.assertTrue(obj.signal.connect(obj.empty, Qt.UniqueConnection)) + self.assertFalse(obj.signal.connect(obj.empty, Qt.UniqueConnection)) if __name__ == '__main__': unittest.main() |