From 05331143ddeee11cdf85a6682da1384eb0da8d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 18 Mar 2021 11:19:09 +0100 Subject: [PATCH] Create timer after setup to prevent crash on startup --- sma/integrationpluginsma.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sma/integrationpluginsma.cpp b/sma/integrationpluginsma.cpp index 242bebe4..1e07df4e 100644 --- a/sma/integrationpluginsma.cpp +++ b/sma/integrationpluginsma.cpp @@ -75,12 +75,6 @@ void IntegrationPluginSma::setupThing(ThingSetupInfo *info) Thing *thing = info->thing(); qCDebug(dcSma()) << "Setup thing" << thing->name(); - if (!m_refreshTimer) { - qCDebug(dcSma()) << "Starting refresh timer"; - m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(1); - connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginSma::onRefreshTimer); - } - if (thing->thingClassId() == sunnyWebBoxThingClassId) { //check if a Sunny WebBox is already added with this IPv4Address foreach(SunnyWebBox *sunnyWebBox, m_sunnyWebBoxes.values()) { @@ -106,6 +100,13 @@ void IntegrationPluginSma::setupThing(ThingSetupInfo *info) connect(sunnyWebBox, &SunnyWebBox::plantOverviewReceived, this, &IntegrationPluginSma::onPlantOverviewReceived); m_sunnyWebBoxes.insert(info->thing(), sunnyWebBox); }); + + if (!m_refreshTimer) { + qCDebug(dcSma()) << "Starting refresh timer"; + m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(1); + connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginSma::onRefreshTimer); + } + } else { Q_ASSERT_X(false, "setupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); }