aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/signals/disconnect_test.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-02-28 16:24:29 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-02-28 19:49:04 +0100
commitad70c1a75af6cd7dbed4c43202c16e65481a2d7d (patch)
tree466151bc657bdf925d38af53aafed9e6267a8fd5 /sources/pyside6/tests/signals/disconnect_test.py
parent91d0ec1e864c5c657e351c32af1f8d78a26c543d (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.py19
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