diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-02-28 16:24:29 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-02-28 19:49:04 +0100 |
| commit | ad70c1a75af6cd7dbed4c43202c16e65481a2d7d (patch) | |
| tree | 466151bc657bdf925d38af53aafed9e6267a8fd5 /sources/pyside6/tests/signals/disconnect_test.py | |
| parent | 91d0ec1e864c5c657e351c32af1f8d78a26c543d (diff) | |
Fix connecting signals by QMetaMethod
The old implementation was calling the string-based overload, but did
not add the '1'/'2' markers added by SIGNAL/SLOT. Call the QObject
overload directly.
Fixes: PYSIDE-1277
Pick-to: 6.8
Change-Id: I912f46c33959b622301b0a75e771057c8874f7e3
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/tests/signals/disconnect_test.py')
| -rw-r--r-- | sources/pyside6/tests/signals/disconnect_test.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sources/pyside6/tests/signals/disconnect_test.py b/sources/pyside6/tests/signals/disconnect_test.py index ee0195777..29ef312b3 100644 --- a/sources/pyside6/tests/signals/disconnect_test.py +++ b/sources/pyside6/tests/signals/disconnect_test.py @@ -95,6 +95,25 @@ class TestDisconnect(unittest.TestCase): s.bar.emit() self.assertEqual(r.called, 1) + def testMetaMethod(self): + s = Sender() + r = Receiver() + sender_mo = s.metaObject() + signal_index = sender_mo.indexOfMethod("bar()") + self.assertTrue(signal_index != -1) + signal_method = sender_mo.method(signal_index) + receiver_mo = r.metaObject() + slot_index = receiver_mo.indexOfMethod("receiver()") + self.assertTrue(slot_index != -1) + slot_method = receiver_mo.method(slot_index) + conn_id = QObject.connect(s, signal_method, r, slot_method) + self.assertTrue(conn_id) + s.bar.emit() + self.assertEqual(r.called, 1) + self.assertTrue(QObject.disconnect(s, signal_method, r, slot_method)) + s.bar.emit() + self.assertEqual(r.called, 1) + def testDuringCallback(self): """ Test to see if the C++ object for a connection is accessed after the method returns. This causes a segfault if the memory that was used by the |
