Schrack: Fix connection leak on failed setup

master
Michael Zanetti 2022-12-31 12:31:29 +01:00
parent 015e25ee13
commit a357794481
1 changed files with 3 additions and 2 deletions

View File

@ -105,12 +105,14 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
} }
}); });
connect(cionConnection, &CionModbusRtuConnection::initializationFinished, info, [info, cionConnection](bool success){ connect(cionConnection, &CionModbusRtuConnection::initializationFinished, info, [=](bool success){
qCDebug(dcSchrack()) << "Initialisation finsihed" << success; qCDebug(dcSchrack()) << "Initialisation finsihed" << success;
if (success) { if (success) {
qCDebug(dcSchrack) << "DIP switche states:" << cionConnection->dipSwitches(); qCDebug(dcSchrack) << "DIP switche states:" << cionConnection->dipSwitches();
m_cionConnections.insert(thing, cionConnection);
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} else { } else {
delete cionConnection;
info->finish(Thing::ThingErrorHardwareNotAvailable); info->finish(Thing::ThingErrorHardwareNotAvailable);
} }
}); });
@ -201,7 +203,6 @@ void IntegrationPluginSchrack::setupThing(ThingSetupInfo *info)
// To prevent running out of sync we'll "uncache" min/max values too. // To prevent running out of sync we'll "uncache" min/max values too.
thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32); thing->setStateMinMaxValues(cionMaxChargingCurrentStateTypeId, 6, 32);
m_cionConnections.insert(thing, cionConnection);
} }
void IntegrationPluginSchrack::postSetupThing(Thing *thing) void IntegrationPluginSchrack::postSetupThing(Thing *thing)