aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue/qtcore.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-16 08:11:29 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-16 11:04:51 +0200
commit3c551005dcb8de4bb083aa934a8fdff1298f14f9 (patch)
treea38307a6bee159e979d22c09651066625cf3956b /sources/pyside2/PySide2/glue/qtcore.cpp
parent92a6f4b71770e0a6e63c8210992ba81448657373 (diff)
Fix slots being invoked from the wrong thread
In case the signal connections are routed via some GlobalReceiverV2 instance, it needs to be moved to the receiver's thread. Fixes: PYSIDE-1354 Change-Id: I85926efeab157e47ec42a830fda024d299807786 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/PySide2/glue/qtcore.cpp')
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 6b23a9b79..306a2239c 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -374,9 +374,15 @@ static bool getReceiver(QObject *source, const char *signal, PyObject *callback,
usingGlobalReceiver = true;
}
+ const auto receiverThread = *receiver ? (*receiver)->thread() : nullptr;
+
if (usingGlobalReceiver) {
PySide::SignalManager &signalManager = PySide::SignalManager::instance();
*receiver = signalManager.globalReceiver(source, callback);
+ // PYSIDE-1354: Move the global receiver to the original receivers's thread
+ // so that autoconnections work correctly.
+ if (receiverThread && receiverThread != (*receiver)->thread())
+ (*receiver)->moveToThread(receiverThread);
*callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toLatin1();
}