From dba629b17386f757c5fcf34bfbed5c8f745ed374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 7 Mar 2022 14:47:54 +0100 Subject: [PATCH] Handle reconfigure --- fronius/froniusnetworkreply.cpp | 2 +- fronius/integrationpluginfronius.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fronius/froniusnetworkreply.cpp b/fronius/froniusnetworkreply.cpp index 13141ae4..34d0ab4c 100644 --- a/fronius/froniusnetworkreply.cpp +++ b/fronius/froniusnetworkreply.cpp @@ -71,7 +71,7 @@ void FroniusNetworkReply::setNetworkReply(QNetworkReply *networkReply) { m_networkReply = networkReply; - // The QNetworkReply will be deleted in the constructor if set + // The QNetworkReply will be deleted in the destructor if set connect(m_networkReply, &QNetworkReply::finished, this, &FroniusNetworkReply::finished); } diff --git a/fronius/integrationpluginfronius.cpp b/fronius/integrationpluginfronius.cpp index 2613977a..934ff50c 100644 --- a/fronius/integrationpluginfronius.cpp +++ b/fronius/integrationpluginfronius.cpp @@ -110,6 +110,15 @@ void IntegrationPluginFronius::setupThing(ThingSetupInfo *info) if (thing->thingClassId() == connectionThingClassId) { QHostAddress address(thing->paramValue(connectionThingAddressParamTypeId).toString()); + + // Handle reconfigure + if (m_froniusConnections.values().contains(thing)) { + FroniusSolarConnection *oldConnection = m_froniusConnections.key(thing); + m_froniusConnections.remove(oldConnection); + oldConnection->deleteLater(); + } + + // Create the connection FroniusSolarConnection *connection = new FroniusSolarConnection(hardwareManager()->networkManager(), address, thing); // Verify the version