From cde5a4dff17c2a26802eb32edc166b0250398e9b Mon Sep 17 00:00:00 2001 From: redPanther Date: Sun, 22 Jan 2017 19:36:52 +0100 Subject: [PATCH] send close signal only on restart to avoid problems while destructiong on normal exit (#376) --- include/hyperion/Hyperion.h | 2 +- libsrc/hyperion/Hyperion.cpp | 9 ++++++--- libsrc/jsonserver/JsonClientConnection.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 4320a63d..26d6be9e 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -70,7 +70,7 @@ public: /// /// free all alocated objects, should be called only from constructor or before restarting hyperion /// - void freeObjects(); + void freeObjects(bool emitCloseSignal=false); static Hyperion* initInstance(const QJsonObject& qjsonConfig, const QString configFile); static Hyperion* getInstance(); diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 53dc5291..70715cfb 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -447,9 +447,12 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) } -void Hyperion::freeObjects() +void Hyperion::freeObjects(bool emitCloseSignal) { - emit closing(); + if (emitCloseSignal) + { + emit closing(); + } // switch off all leds clearall(); @@ -464,7 +467,7 @@ void Hyperion::freeObjects() Hyperion::~Hyperion() { - freeObjects(); + freeObjects(false); } unsigned Hyperion::getLedCount() const diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index e5ef87a8..4773eb11 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -930,7 +930,7 @@ void JsonClientConnection::handleConfigCommand(const QJsonObject& message, const } else if (subcommand == "reload") { - _hyperion->freeObjects(); + _hyperion->freeObjects(true); Process::restartHyperion(); sendErrorReply("failed to restart hyperion", full_command, tan); }