summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2021-12-08 22:44:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-14 22:39:57 +0000
commit9a7f69fe2e98497937452ce54b364e563e10f54b (patch)
tree6c6019a5ddc8f68a6ab48733ee1d41505318c4ec
parentb737c8d28813032f4f6b5a01a8cb8e19166f7ad3 (diff)
downloadqtwebchannel-9a7f69fe2e98497937452ce54b364e563e10f54b.tar.gz
QMetaObjectPublisher: Never send stale queued messages
If the client is connected with an in-process transport, it can happen that a transmitted message triggers a subsequent property change. In that case, we need to ensure that the queued messages have already been cleared; otherwise the recursive call will send everythig again. Case in point: The qmlwebchannel tests fail if we don't clear the queued messages before sending them out. For that same reason set the client to "busy" (aka non-idle) just right before sending out the messages; otherwise a potential "Idle" type message will not correctly restore the Idle state. Change-Id: Idc4afdd5cf4b4e03b8de8953a03d28442d74a3ab Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b4bf8f5e043120341cd9caa59f25a2beecd94ad0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index 53cf840..891614c 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -978,11 +978,23 @@ void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransp
auto found = transportState.find(transport);
if (found != transportState.end() && found.value().clientIsIdle
&& !found.value().queuedMessages.isEmpty()) {
- for (auto message : found.value().queuedMessages) {
+
+ // If the client is connected with an in-process transport, it can
+ // happen that a message triggers a subsequent property change. In
+ // that case, we need to ensure that the queued messages have already
+ // been cleared; otherwise the recursive call will send everythig again.
+ // Case in point: The qmlwebchannel tests fail if we don't clear the
+ // queued messages before sending them out.
+ // For that same reason set the client to "busy" (aka non-idle) just
+ // right before sending out the messages; otherwise a potential
+ // "Idle" type message will not correctly restore the Idle state.
+ const auto messages = std::move(found.value().queuedMessages);
+ Q_ASSERT(found.value().queuedMessages.isEmpty());
+ found.value().clientIsIdle = false;
+
+ for (const auto &message : messages) {
transport->sendMessage(message);
}
- found.value().queuedMessages.clear();
- found.value().clientIsIdle = false;
}
}