diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2019-12-13 18:07:26 +0100 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2021-04-16 14:04:38 +0200 |
commit | 28455e59c0b940200fe0223472a80104ce1a02dd (patch) | |
tree | 73ee9356efac20f704e43213250bcc6f46f761ad /src/webchannel/qmetaobjectpublisher_p.h | |
parent | e4c7122d78e4f8dccc246a027cde1bf43a87841d (diff) |
Handle signals in the registered object's thread
Do not call `sender()` from a different thread. As the API documentation
indicates, that is not supported and can lead to crashes as experienced
on the CI frequently.
Instead, we now have per-thread SignalHandlers and use those to get
notified about signals and metacall events.
Moving a registered object into a different thread isn't supported once
it was registered. But the object can be deregistered, moved, and then
re-registered.
[ChangeLog] Signals from objects living in a different thread than the
QWebChannel are now handled correctly.
Task-number: QTBUG-51366
Change-Id: I1edb0694b946a494b6c0d4a8a6dc6b452dcb2c7a
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/webchannel/qmetaobjectpublisher_p.h')
-rw-r--r-- | src/webchannel/qmetaobjectpublisher_p.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/webchannel/qmetaobjectpublisher_p.h b/src/webchannel/qmetaobjectpublisher_p.h index 5e57e8c..e87e4f0 100644 --- a/src/webchannel/qmetaobjectpublisher_p.h +++ b/src/webchannel/qmetaobjectpublisher_p.h @@ -60,6 +60,8 @@ #include <QPointer> #include <QJsonObject> +#include <unordered_map> + #include "qwebchannelglobal.h" QT_BEGIN_NAMESPACE @@ -275,7 +277,8 @@ private: friend class TestWebChannel; QWebChannel *webChannel; - SignalHandler<QMetaObjectPublisher> signalHandler; + std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers; + SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object); // true when the client is idle, false otherwise bool clientIsIdle; |