summaryrefslogtreecommitdiffstats
path: root/src/mqtt/qmqttclient.cpp
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2018-02-15 11:58:16 +0100
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2018-02-16 06:11:49 +0000
commit62accf0dc505546ac6f8da4a589fe1d7b86bc49c (patch)
tree0b7e30e58fb3c096790ec1b0eb9e74954f48a3c2 /src/mqtt/qmqttclient.cpp
parent813f4a7e8652484283c65fa275e133addbb0bb24 (diff)
Fix disconnectFromHost when in connecting state
While the client or rather its underlying transport is trying to connect to a broker, a user might want to cancel this step by calling disconnectFromHost. Previously there was an early return, which lead to the client being in a bogus state. Task-number: QTBUG-66412 Change-Id: If6e9b778b8d10f7951631ebd1a0017c870ba6c18 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/mqtt/qmqttclient.cpp')
-rw-r--r--src/mqtt/qmqttclient.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mqtt/qmqttclient.cpp b/src/mqtt/qmqttclient.cpp
index 23fb00f..8cf1661 100644
--- a/src/mqtt/qmqttclient.cpp
+++ b/src/mqtt/qmqttclient.cpp
@@ -443,10 +443,17 @@ void QMqttClient::disconnectFromHost()
{
Q_D(QMqttClient);
- if (d->m_connection.internalState() != QMqttConnection::BrokerConnected)
+ switch (d->m_connection.internalState()) {
+ case QMqttConnection::BrokerConnected:
+ d->m_connection.sendControlDisconnect();
+ case QMqttConnection::BrokerDisconnected:
return;
-
- d->m_connection.sendControlDisconnect();
+ case QMqttConnection::BrokerConnecting:
+ case QMqttConnection::BrokerWaitForConnectAck:
+ default:
+ d->m_connection.m_transport->close();
+ break;
+ }
}
QMqttClient::ClientState QMqttClient::state() const