From 254382acf640b1b32404ef66aa2a3fe98ead68ae Mon Sep 17 00:00:00 2001 From: Robert Stanley Judka Date: Sat, 16 May 2020 19:14:48 -0500 Subject: [PATCH] fix fragile qtvideooutput (#3) --- src/autoapp/Service/ServiceFactory.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/autoapp/Service/ServiceFactory.cpp b/src/autoapp/Service/ServiceFactory.cpp index 55ef7cf..cee69a9 100644 --- a/src/autoapp/Service/ServiceFactory.cpp +++ b/src/autoapp/Service/ServiceFactory.cpp @@ -57,6 +57,8 @@ ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration , activeCallback_(activeCallback) #ifdef USE_OMX , omxVideoOutput_(std::make_shared(configuration_, this->QRectToDestRect(screenGeometry_), activeCallback_)) +#else + , qtVideoOutput_(nullptr) #endif , nightMode_(nightMode) { @@ -90,7 +92,11 @@ IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenge qtVideoOutput_ = new projection::QtVideoOutput(configuration_, activeArea_); if (activeCallback_ != nullptr) { QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::startPlayback, [callback = activeCallback_]() { callback(true); }); - QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::stopPlayback, [callback = activeCallback_]() { callback(false); }); + QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::stopPlayback, [this]() { + activeCallback_(false); + qtVideoOutput_->disconnect(); + qtVideoOutput_ = nullptr; + }); } projection::IVideoOutput::Pointer videoOutput(qtVideoOutput_, std::bind(&QObject::deleteLater, std::placeholders::_1)); #endif