diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index f320e197..4320a63d 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -289,6 +289,7 @@ signals: void imageToLedsMappingChanged(int mappingType); void emitImage(int priority, const Image & image, const int timeout_ms); + void closing(); private slots: /// diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 8e71406b..c04587f7 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -74,6 +74,7 @@ V4L2Grabber::~V4L2Grabber() void V4L2Grabber::uninit() { + Debug(_log,"uninit grabber: %s", _deviceName.c_str()); // stop if the grabber was not stopped if (_initialized) { diff --git a/libsrc/hyperion/GrabberWrapper.cpp b/libsrc/hyperion/GrabberWrapper.cpp index 2ef9951d..dcdd28de 100644 --- a/libsrc/hyperion/GrabberWrapper.cpp +++ b/libsrc/hyperion/GrabberWrapper.cpp @@ -27,6 +27,8 @@ GrabberWrapper::GrabberWrapper(std::string grabberName, const int priority, hype GrabberWrapper::~GrabberWrapper() { + stop(); + Debug(_log,"Close grabber: %s", _grabberName.c_str()); delete _processor; } diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index c6f17504..53dc5291 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -449,6 +449,8 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) void Hyperion::freeObjects() { + emit closing(); + // switch off all leds clearall(); _device->switchOff(); diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 820a23ef..08929a55 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -1,11 +1,18 @@ +SET(Hyperiond_QT_HEADERS + hyperiond.h +) + +QT5_WRAP_CPP(Hyperiond_HEADERS_MOC ${Hyperiond_QT_HEADERS}) + add_executable(hyperiond + ${Hyperiond_QT_HEADERS} + ${Hyperiond_HEADERS_MOC} configMigratorBase.cpp configMigratorBase.h configMigrator.cpp configMigrator.h hyperiond.cpp - hyperiond.h main.cpp ) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 781504ff..77bb9196 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -79,6 +79,13 @@ HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent) HyperionDaemon::~HyperionDaemon() { + freeObjects(); + delete _hyperion; +} + +void HyperionDaemon::freeObjects() +{ + Debug(_log, "destroy grabbers and network stuff"); delete _amlGrabber; delete _dispmanx; delete _fbGrabber; @@ -92,8 +99,17 @@ HyperionDaemon::~HyperionDaemon() delete _protoServer; delete _boblightServer; delete _udpListener; - delete _hyperion; + _v4l2Grabbers.clear(); + _amlGrabber = nullptr; + _dispmanx = nullptr; + _fbGrabber = nullptr; + _osxGrabber = nullptr; + _kodiVideoChecker = nullptr; + _jsonServer = nullptr; + _protoServer = nullptr; + _boblightServer = nullptr; + _udpListener = nullptr; } void HyperionDaemon::run() @@ -113,7 +129,7 @@ void HyperionDaemon::run() #endif Info(_log, "Hyperion started"); - + connect(_hyperion,SIGNAL(closing()),this,SLOT(freeObjects())); } int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVersion) diff --git a/src/hyperiond/hyperiond.h b/src/hyperiond/hyperiond.h index f5dce843..a1f3acd7 100644 --- a/src/hyperiond/hyperiond.h +++ b/src/hyperiond/hyperiond.h @@ -49,6 +49,7 @@ class HyperionDaemon : public QObject { + Q_OBJECT public: HyperionDaemon(QString configFile, QObject *parent=nullptr); ~HyperionDaemon(); @@ -65,6 +66,9 @@ public: void createGrabberV4L2(); void createSystemFrameGrabber(); +public slots: + void freeObjects(); + private: void createGrabberDispmanx(); void createGrabberAmlogic();