From 9ff834b7ffd9f942bf74ea1272b32273304310f9 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 16 Apr 2019 23:44:06 +0200 Subject: [PATCH] Do a more controlled teardown on shutdown --- libnymea-core/nymeacore.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libnymea-core/nymeacore.cpp b/libnymea-core/nymeacore.cpp index a5a70cd1..149fd3c1 100644 --- a/libnymea-core/nymeacore.cpp +++ b/libnymea-core/nymeacore.cpp @@ -216,25 +216,32 @@ NymeaCore::~NymeaCore() { m_logger->logSystemEvent(m_timeManager->currentDateTime(), false); - // Make sure DeviceManager is teared down at first so plugins don't access any resources any more. + // Disconnect everything that could still spawn events + disconnect(m_deviceManager); + disconnect(m_ruleEngine); + disconnect(m_timeManager); + + // At very first, cut off the outside world + qCDebug(dcApplication) << "Shutting down \"Server Manager\""; + delete m_serverManager; + qCDebug(dcApplication) << "Shutting down \"CloudManager\""; + delete m_cloudManager; + + // Then stop magic from happening + qCDebug(dcApplication) << "Shutting down \"Rule Engine\""; + delete m_ruleEngine; + + // Next, DeviceManager, so plugins don't access any resources any more. qCDebug(dcApplication) << "Shutting down \"Device Manager\""; delete m_deviceManager; + // Now go ahead and clean up stuff. qCDebug(dcApplication) << "Shutting down \"Log Engine\""; delete m_logger; qCDebug(dcApplication()) << "Shutting down \"Hardware Manager\""; delete m_hardwareManager; - qCDebug(dcApplication) << "Shutting down \"Rule Engine\""; - delete m_ruleEngine; - - qCDebug(dcApplication) << "Shutting down \"Server Manager\""; - delete m_serverManager; - - qCDebug(dcApplication) << "Shutting down \"CloudManager\""; - delete m_cloudManager; - qCDebug(dcApplication) << "Done shutting down NymeaCore"; }