fixed memory leaks on setup
This commit is contained in:
parent
2ae998e707
commit
69e6736494
@ -237,10 +237,15 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
|
|
||||||
qCDebug(dcHomeConnect()) << "Setuo thing" << thing->name();
|
qCDebug(dcHomeConnect()) << "Setup thing" << thing->name();
|
||||||
if (thing->thingClassId() == homeConnectAccountThingClassId) {
|
if (thing->thingClassId() == homeConnectAccountThingClassId) {
|
||||||
bool simulationMode = configValue(homeConnectPluginSimulationModeParamTypeId).toBool();
|
bool simulationMode = configValue(homeConnectPluginSimulationModeParamTypeId).toBool();
|
||||||
HomeConnect *homeConnect;
|
HomeConnect *homeConnect;
|
||||||
|
|
||||||
|
if (m_homeConnectConnections.contains(thing)) {
|
||||||
|
qCDebug(dcHomeConnect()) << "Setup after reconfiguration, cleaning up";
|
||||||
|
m_homeConnectConnections.take(thing)->deleteLater();
|
||||||
|
}
|
||||||
if (m_setupHomeConnectConnections.keys().contains(thing->id())) {
|
if (m_setupHomeConnectConnections.keys().contains(thing->id())) {
|
||||||
//Fresh device setup, has already a fresh access token
|
//Fresh device setup, has already a fresh access token
|
||||||
qCDebug(dcHomeConnect()) << "HomeConnect OAuth setup complete";
|
qCDebug(dcHomeConnect()) << "HomeConnect OAuth setup complete";
|
||||||
@ -265,12 +270,16 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||||||
qCDebug(dcHomeConnect()) << "Using custom API key and secret.";
|
qCDebug(dcHomeConnect()) << "Using custom API key and secret.";
|
||||||
}
|
}
|
||||||
if (clientKey.isEmpty() || clientSecret.isEmpty()) {
|
if (clientKey.isEmpty() || clientSecret.isEmpty()) {
|
||||||
info->finish(Thing::ThingErrorAuthenticationFailure, tr("Client key and/or seceret is not available."));
|
info->finish(Thing::ThingErrorAuthenticationFailure, tr("Client key and/or secret is not available."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
homeConnect = new HomeConnect(hardwareManager()->networkManager(), clientKey, clientSecret, simulationMode, this);
|
homeConnect = new HomeConnect(hardwareManager()->networkManager(), clientKey, clientSecret, simulationMode, this);
|
||||||
homeConnect->getAccessTokenFromRefreshToken(refreshToken);
|
homeConnect->getAccessTokenFromRefreshToken(refreshToken);
|
||||||
m_asyncSetup.insert(homeConnect, info);
|
m_asyncSetup.insert(homeConnect, info);
|
||||||
|
connect(info, &ThingSetupInfo::aborted, homeConnect, [homeConnect, this] {
|
||||||
|
m_asyncSetup.remove(homeConnect);
|
||||||
|
homeConnect->deleteLater();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
connect(homeConnect, &HomeConnect::connectionChanged, this, &IntegrationPluginHomeConnect::onConnectionChanged);
|
connect(homeConnect, &HomeConnect::connectionChanged, this, &IntegrationPluginHomeConnect::onConnectionChanged);
|
||||||
connect(homeConnect, &HomeConnect::commandExecuted, this, &IntegrationPluginHomeConnect::onRequestExecuted);
|
connect(homeConnect, &HomeConnect::commandExecuted, this, &IntegrationPluginHomeConnect::onRequestExecuted);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user