diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-10-19 22:01:33 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-10-21 10:13:25 +0200 |
| commit | e7c2b6ea1645065a64c2385498e7bd452e47c1ec (patch) | |
| tree | d816727d6ec7c61a3560e58826f942e63d39be4a /sources/pyside6 | |
| parent | bdd6a0d5d61aa76c202669ae1c17ef4dfe0b9bde (diff) | |
Fix error handling in non-slot connection receivers
Extract the error handling code which existed duplicated in
GlobalReceiverV2::qt_metacall() and
SignalManagerPrivate::handleMetaCallError() as a static helper of
SignalManager and call that from the DynamicSlot functions.
Amends 33bd61d13d8d9e3794b6049891be62f3351313d9.
Pick-to: 6.8 6.8.0
Task-number: PYSIDE-2810
Fixes: PYSIDE-2900
Change-Id: Ife9f156e6752dde7002218d36d369ba68ad595b0
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6')
| -rw-r--r-- | sources/pyside6/libpyside/dynamicslot.cpp | 8 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/signalmanager.cpp | 4 | ||||
| -rw-r--r-- | sources/pyside6/libpyside/signalmanager.h | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/sources/pyside6/libpyside/dynamicslot.cpp b/sources/pyside6/libpyside/dynamicslot.cpp index ce8ed191c..1fbdba1ab 100644 --- a/sources/pyside6/libpyside/dynamicslot.cpp +++ b/sources/pyside6/libpyside/dynamicslot.cpp @@ -65,6 +65,10 @@ void CallbackDynamicSlot::call(const QByteArrayList ¶meterTypes, const char void **cppArgs) { SignalManager::callPythonMetaMethod(parameterTypes, returnType, cppArgs, m_callback); + // SignalManager::callPythonMetaMethod might have failed, in that case we have to print the + // error so it considered "handled". + if (PyErr_Occurred() != nullptr) + SignalManager::handleMetaCallError(); } void CallbackDynamicSlot::formatDebug(QDebug &debug) const @@ -116,6 +120,10 @@ void MethodDynamicSlot::call(const QByteArrayList ¶meterTypes, const char *r m_pythonSelf, nullptr)); SignalManager::callPythonMetaMethod(parameterTypes, returnType, cppArgs, callable.object()); + // SignalManager::callPythonMetaMethod might have failed, in that case we have to print the + // error so it considered "handled". + if (PyErr_Occurred() != nullptr) + SignalManager::handleMetaCallError(); } void MethodDynamicSlot::formatDebug(QDebug &debug) const diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp index 35116648b..c3d66f3bc 100644 --- a/sources/pyside6/libpyside/signalmanager.cpp +++ b/sources/pyside6/libpyside/signalmanager.cpp @@ -300,7 +300,11 @@ void SignalManagerPrivate::handleMetaCallError(QObject *object, int *result) if (idOpt.has_value()) *result = idOpt.value(); } + SignalManager::handleMetaCallError(); +} +void SignalManager::handleMetaCallError() +{ const int reclimit = Py_GetRecursionLimit(); // Inspired by Python's errors.c: PyErr_GivenExceptionMatches() function. // Temporarily bump the recursion limit, so that PyErr_Print will not raise a recursion diff --git a/sources/pyside6/libpyside/signalmanager.h b/sources/pyside6/libpyside/signalmanager.h index 84d6b773e..ee39a3a8d 100644 --- a/sources/pyside6/libpyside/signalmanager.h +++ b/sources/pyside6/libpyside/signalmanager.h @@ -80,6 +80,7 @@ public: static int callPythonMetaMethod(const QByteArrayList ¶meterTypes, const char *returnType /* = nullptr */, void **args, PyObject *callable); + static void handleMetaCallError(); }; } |
