diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-06-25 08:15:50 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-06-26 14:35:41 +0200 |
| commit | 816474711c6890b41c9254bb0a343311268be692 (patch) | |
| tree | 82be76d084b02c27ce98db16dda29b9b9c9e9cbb /sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py | |
| parent | 16098891ad21c2ba984582a1de770e49f961f22b (diff) | |
shiboken6: Prevent converter name clashes between classes and partially qualified aliases
Change the behavior of registerConverterName() to always overwrite
existing entries. It should then only be used for fully qualified
names. Add a function registerConverterAlias() which does not
overwrite existing entries for registering partially qualified names.
Use registerConverterAlias() for the primitive types since they
are re-registered in multiple modules.
This prevents clashes when registering duplicate classes. For example,
registering a globally scoped class "Connection" will then overwrite
the partially qualified alias "Connection" of
"QMetaObject::Connection".
Fixes: PYSIDE-2792
Change-Id: I2bd3c0bff96da6d3ceddd46a2368fe6b94bbed68
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py')
| -rw-r--r-- | sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py b/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py index b1b69a679..34b8f7f62 100644 --- a/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py +++ b/sources/pyside6/tests/pysidetest/signalemissionfrompython_test.py @@ -13,12 +13,26 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(True) -from testbinding import TestObject -from PySide6.QtCore import QObject, SIGNAL +# Note: For PYSIDE-2792/testConnectionSignal()), QMetaObject needs to be +# forcibly created before Connection. +from PySide6.QtCore import QObject, SIGNAL, Slot, QMetaObject # noqa: F401 +from testbinding import TestObject, Connection '''Tests the behaviour of signals with default values when emitted from Python.''' +class Receiver(QObject): + """Test receiver for PYSIDE-2792 (testConnectionSignal).""" + + def __init__(self, p=None): + super().__init__(p) + self.received_handle = -1 + + @Slot(Connection) + def connectionSlot(self, c): + self.received_handle = c.handle() + + class SignalEmissionFromPython(unittest.TestCase): def setUp(self): @@ -49,6 +63,15 @@ class SignalEmissionFromPython(unittest.TestCase): self.assertEqual(self.one_called, 1) self.assertEqual(self.two_called, 2) + def testConnectionSignal(self): + """PYSIDE-2792: Test whether a signal parameter of type 'Connection' + clashes with QMetaObject.Connection.""" + receiver = Receiver() + qmetaobject_conn = self.obj1.connectionSignal.connect(receiver.connectionSlot) + self.assertTrue(qmetaobject_conn) + self.obj1.emitConnectionSignal(42) + self.assertEqual(receiver.received_handle, 42) + def testConnectOldStyleEmitVoidSignal(self): def callbackOne(): self.one_called += 1 @@ -94,4 +117,3 @@ class SignalEmissionFromPython(unittest.TestCase): if __name__ == '__main__': unittest.main() - |
