From c6d5364300ca8106b557dfec84d3ebc62b525ed3 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 23 Nov 2022 17:36:59 +0100 Subject: [PATCH] Fix a warning and improve debug print when a client times out Old code would implicitly delete the client by the call to abort() as well as scheduling a deleteLater() which caused a unexpeted null receiver warning. --- libnymea-mqtt/mqttserver.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libnymea-mqtt/mqttserver.cpp b/libnymea-mqtt/mqttserver.cpp index fef07f1..afd9498 100644 --- a/libnymea-mqtt/mqttserver.cpp +++ b/libnymea-mqtt/mqttserver.cpp @@ -231,10 +231,9 @@ void MqttServerPrivate::onClientConnected(MqttServerClient *client) // Start a 10 second timer to clean up the connection if we don't get data until then. QTimer *timeoutTimer = new QTimer(this); connect(timeoutTimer, &QTimer::timeout, client, [this, client]() { - qCWarning(dbgServer) << "A client connected but did not send data in 10 seconds. Dropping connection."; - client->abort(); + qCWarning(dbgServer) << "A client connected but did not send data in 10 seconds. Dropping connection from" << client->peerAddress(); pendingConnections.take(client)->deleteLater(); - client->deleteLater(); + client->abort(); }); timeoutTimer->start(10000); clientServerMap.insert(client, transport);