all repos — mgba @ 3aa74f2d6528d94f0c4ab8a5e5e608121bee8c0e

mGBA Game Boy Advance Emulator

Qt: Fix proxied events blocking properly
Vicki Pfau vi@endrift.com
Fri, 04 Dec 2020 00:23:07 -0800
commit

3aa74f2d6528d94f0c4ab8a5e5e608121bee8c0e

parent

2f7232292c79ddaefaef9db3b950b40720b3d6e2

2 files changed, 2 insertions(+), 8 deletions(-)

jump to
M src/platform/qt/VideoProxy.cppsrc/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.hsrc/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();