From 08d61b56fa9e901b807b67b07f187e0f54e7551c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Jul 2024 10:38:45 +0200 Subject: libpyside: Fix parameters for connections with contexts Use the new SignalManager::callPythonMetaMethod() overload introduced by ed8fc457e04f4ead8a3b2a2da797bdc14bd5b210 in PySideQSlotObject to convert the void ** arguments to Python. Amends acab25a3ccb836818e5089b23d40196bc7414b7a. Change-Id: I024bc7f8df7fa65b8b1761f517a99a854de2cec8 Reviewed-by: Cristian Maureira-Fredes --- .../pyside6/tests/signals/signal_emission_test.py | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'sources/pyside6/tests') diff --git a/sources/pyside6/tests/signals/signal_emission_test.py b/sources/pyside6/tests/signals/signal_emission_test.py index 769b1839a..b0c02b084 100644 --- a/sources/pyside6/tests/signals/signal_emission_test.py +++ b/sources/pyside6/tests/signals/signal_emission_test.py @@ -15,7 +15,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtCore import QObject, Signal, SIGNAL, QProcess, QTimeLine +from PySide6.QtCore import QObject, Signal, SIGNAL, QProcess, QTimeLine, Slot from helper.usesqapplication import UsesQApplication @@ -45,6 +45,18 @@ class Sender(QObject): dummy_int = Signal(int) +class Receiver(QObject): + '''Receiver class''' + + def __init__(self, p=None): + super().__init__(p) + self.n = 0 + + @Slot(int) + def intSlot(self, n): + self.n = n + + class PythonSignalToCppSlots(UsesQApplication): '''Connect python signals to C++ slots''' @@ -75,6 +87,18 @@ class PythonSignalToCppSlots(UsesQApplication): self.assertEqual(timeline.currentTime(), current + 42) +class ConnectWithContext(UsesQApplication): + '''Test whether a connection with context QObject passes parameters.''' + + def testIt(self): + sender = Sender() + receiver = Receiver() + context = sender + QObject.connect(sender, SIGNAL("dummy_int(int)"), context, receiver.intSlot) + sender.dummy_int.emit(42) + self.assertEqual(receiver.n, 42) + + class CppSignalsToCppSlots(UsesQApplication): '''Connection between C++ slots and signals''' -- cgit v1.2.3