diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-24 09:44:24 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-24 15:30:48 +0200 |
| commit | 310e206765cbaadee33da8d5098a053ad42b5b67 (patch) | |
| tree | cb1e705cd27360bfbada03e6e87b93c02588ba0e /sources/pyside6/libpyside/qobjectconnect.cpp | |
| parent | e279142681b10a5edba36cc7c80750168f13cee6 (diff) | |
Fix threading deadlocks of QObject::(dis)connect() with (dis)connectNotify()
Do the connect/disconnect within allow-threads.
Fixes: PYSIDE-2367
Pick-to: 6.6 6.5
Change-Id: I95c908d438a4a6c9cd0a23d3fce31a53e02ea19d
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/qobjectconnect.cpp')
| -rw-r--r-- | sources/pyside6/libpyside/qobjectconnect.cpp | 11 |
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); |
