diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2020-12-24 13:50:38 +0300 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2021-01-04 09:52:17 +0000 |
commit | e3a4fe42a1571fc4893fe09da1e50b17ae65b41f (patch) | |
tree | cc8d0715822532c6fc58a7e05a28bd274e844b0f | |
parent | 215f7380b9aae577b61670f66248fc08921a0adf (diff) |
Ensure error gets reported for the state in which it has been occurred
In certain scenarios, it is important to distinguish errors occurred
within particular states.
A common example is: if network error occurred for a connected
and operational client, one could try to reconnect and restore
previous MQTT session using the same clientId and cleanSession=false,
without having to bother the user if that succeуded;
however if network error occurred during connection to MQTT broker,
the behavior is completely different.
Change-Id: Id1e90b7916f3e2ab32320518d0da1100014e5dd1
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r-- | src/mqtt/qmqttclient.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/mqtt/qmqttclient.cpp b/src/mqtt/qmqttclient.cpp index 5fe62e3..0df7ca1 100644 --- a/src/mqtt/qmqttclient.cpp +++ b/src/mqtt/qmqttclient.cpp @@ -1063,10 +1063,9 @@ void QMqttClientPrivate::setStateAndError(QMqttClient::ClientState s, QMqttClien { Q_Q(QMqttClient); - if (s != m_state) - q->setState(s); - if (e != QMqttClient::NoError && m_error != e) + if (e != QMqttClient::NoError) q->setError(e); + q->setState(s); } void QMqttClientPrivate::setClientId(const QString &id) |