From 3aa74f2d6528d94f0c4ab8a5e5e608121bee8c0e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 4 Dec 2020 00:23:07 -0800 Subject: [PATCH] Qt: Fix proxied events blocking properly --- src/platform/qt/VideoProxy.cpp | 9 ++------- src/platform/qt/VideoProxy.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/platform/qt/VideoProxy.cpp b/src/platform/qt/VideoProxy.cpp index c188f5b78..60cb938b8 100644 --- a/src/platform/qt/VideoProxy.cpp +++ b/src/platform/qt/VideoProxy.cpp @@ -29,7 +29,6 @@ VideoProxy::VideoProxy() { m_logger.d.postEvent = &callback::func<&VideoProxy::postEvent>; connect(this, &VideoProxy::dataAvailable, this, &VideoProxy::processData); - connect(this, &VideoProxy::eventPosted, this, &VideoProxy::handleEvent); } void VideoProxy::attach(CoreController* controller) { @@ -98,19 +97,15 @@ bool VideoProxy::readData(void* data, size_t length, bool block) { void VideoProxy::postEvent(enum mVideoLoggerEvent event) { if (QThread::currentThread() == thread()) { // We're on the main thread - emit eventPosted(event); + handleEvent(event); } else { - m_mutex.lock(); - emit eventPosted(event); - m_fromThreadCond.wait(&m_mutex, 1); - m_mutex.unlock(); + QMetaObject::invokeMethod(this, "handleEvent", Qt::BlockingQueuedConnection, Q_ARG(int, event)); } } void VideoProxy::handleEvent(int event) { m_mutex.lock(); m_logger.d.handleEvent(&m_logger.d, static_cast(event)); - m_fromThreadCond.wakeAll(); m_mutex.unlock(); } diff --git a/src/platform/qt/VideoProxy.h b/src/platform/qt/VideoProxy.h index 9376515f4..3ba845617 100644 --- a/src/platform/qt/VideoProxy.h +++ b/src/platform/qt/VideoProxy.h @@ -28,7 +28,6 @@ public: signals: void dataAvailable(); - void eventPosted(int); public slots: void processData();