diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 7cf89afb..c2ba3992 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -78,6 +78,10 @@ public: /// ~Hyperion(); + /// + /// free all alocated objects, should be called only from constructor or before restarting hyperion + /// + void freeObjects(); static Hyperion* initInstance(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile); static Hyperion* getInstance(); diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 9cda1b95..f82c3f24 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -594,7 +594,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig } -Hyperion::~Hyperion() +void Hyperion::freeObjects() { // switch off all leds clearall(); @@ -608,6 +608,11 @@ Hyperion::~Hyperion() delete _messageForwarder; } +Hyperion::~Hyperion() +{ + freeObjects(); +} + unsigned Hyperion::getLedCount() const { return _ledString.leds().size(); diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 85a6af95..676f8e29 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -903,6 +903,7 @@ void JsonClientConnection::handleConfigCommand(const QJsonObject& message, const } else if (subcommand == "reload") { + _hyperion->freeObjects(); Process::restartHyperion(); sendErrorReply("failed to restart hyperion", full_command, tan); }