From 7b483bb087d4b26207422ca00dde534446008cc8 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 28 Nov 2018 12:20:16 +0100 Subject: [PATCH] don't leak policies --- .../hardware/network/mqtt/mqttproviderimplementation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnymea-core/hardware/network/mqtt/mqttproviderimplementation.cpp b/libnymea-core/hardware/network/mqtt/mqttproviderimplementation.cpp index cbd878c2..c1f9c235 100644 --- a/libnymea-core/hardware/network/mqtt/mqttproviderimplementation.cpp +++ b/libnymea-core/hardware/network/mqtt/mqttproviderimplementation.cpp @@ -111,6 +111,11 @@ MqttClient *MqttProviderImplementation::createInternalClient(const DeviceId &dev client->setPassword(policy.password); client->setAutoReconnect(false); + connect(client, &MqttClient::destroyed, this, [this, clientId]() { + qCDebug(dcMqtt) << "Internal MQTT client destroyed. Removing policy"; + m_broker->removePolicy(clientId); + }); + if (preferredConfig.address == QHostAddress::Any || preferredConfig.address == QHostAddress::AnyIPv4 || preferredConfig.address == QHostAddress::LocalHost) {