Qt: Fix proxied events blocking properly
Vicki Pfau vi@endrift.com
Fri, 04 Dec 2020 00:23:07 -0800
2 files changed,
2 insertions(+),
8 deletions(-)
M
src/platform/qt/VideoProxy.cpp
→
src/platform/qt/VideoProxy.cpp
@@ -29,7 +29,6 @@ m_logger.d.readData = &callback<bool, void*, size_t, bool>::func<&VideoProxy::readData>;
m_logger.d.postEvent = &callback<void, enum mVideoLoggerEvent>::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 @@
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<enum mVideoLoggerEvent>(event)); - m_fromThreadCond.wakeAll(); m_mutex.unlock(); }
M
src/platform/qt/VideoProxy.h
→
src/platform/qt/VideoProxy.h
@@ -28,7 +28,6 @@ void setBlocking(bool block) { m_logger.d.waitOnFlush = block; }
signals: void dataAvailable(); - void eventPosted(int); public slots: void processData();