aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-24 09:44:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-10-24 22:10:42 +0000
commit5f5d7e0fc6aff4a3911686783e22125803cb33dc (patch)
tree67f49b698f250eff402daaf72f46567fb5c60bec
parent37e150c69febeed71c18f9f9edc10cd0102f42a7 (diff)
Fix threading deadlocks of QObject::(dis)connect() with (dis)connectNotify()
Do the connect/disconnect within allow-threads. Fixes: PYSIDE-2367 Change-Id: I95c908d438a4a6c9cd0a23d3fce31a53e02ea19d Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit 310e206765cbaadee33da8d5098a053ad42b5b67) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 5d6f08b82204df7cd5165c9e57ea81b83fae8064)
-rw-r--r--sources/pyside6/libpyside/qobjectconnect.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/pyside6/libpyside/qobjectconnect.cpp b/sources/pyside6/libpyside/qobjectconnect.cpp
index e0b146e06..15b71766c 100644
--- a/sources/pyside6/libpyside/qobjectconnect.cpp
+++ b/sources/pyside6/libpyside/qobjectconnect.cpp
@@ -240,7 +240,10 @@ QMetaObject::Connection qobjectConnectCallback(QObject *source, const char *sign
}
}
- auto connection = QMetaObject::connect(source, signalIndex, receiver.receiver, slotIndex, type);
+ QMetaObject::Connection connection{};
+ Py_BEGIN_ALLOW_THREADS // PYSIDE-2367, prevent threading deadlocks with connectNotify()
+ connection = QMetaObject::connect(source, signalIndex, receiver.receiver, slotIndex, type);
+ Py_END_ALLOW_THREADS
if (!connection) {
if (receiver.usingGlobalReceiver)
signalManager.releaseGlobalReceiver(source, receiver.receiver);
@@ -269,7 +272,11 @@ bool qobjectDisconnectCallback(QObject *source, const char *signal, PyObject *ca
const int signalIndex = source->metaObject()->indexOfSignal(signal + 1);
const int slotIndex = receiver.slotIndex;
- if (!QMetaObject::disconnectOne(source, signalIndex, receiver.receiver, slotIndex))
+ bool ok{};
+ Py_BEGIN_ALLOW_THREADS // PYSIDE-2367, prevent threading deadlocks with disconnectNotify()
+ ok = QMetaObject::disconnectOne(source, signalIndex, receiver.receiver, slotIndex);
+ Py_END_ALLOW_THREADS
+ if (!ok)
return false;
Q_ASSERT(receiver.receiver);