mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix race condition with proxied video events
This commit is contained in:
parent
d044c05f30
commit
541715008b
1
CHANGES
1
CHANGES
|
@ -1,6 +1,7 @@
|
|||
0.9.0: (Future)
|
||||
Other fixes:
|
||||
- Qt: Only dynamically reset video scale if a game is running
|
||||
- Qt: Fix race condition with proxied video events
|
||||
|
||||
0.8.0: (2020-01-21)
|
||||
Features:
|
||||
|
|
|
@ -138,6 +138,7 @@ static void _postEvent(struct mVideoLogger* logger, enum mVideoLoggerEvent event
|
|||
MutexLock(&proxyRenderer->mutex);
|
||||
proxyRenderer->event = event;
|
||||
ConditionWake(&proxyRenderer->toThreadCond);
|
||||
ConditionWait(&proxyRenderer->fromThreadCond, &proxyRenderer->mutex);
|
||||
MutexUnlock(&proxyRenderer->mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "CoreController.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
using namespace QGBA;
|
||||
|
||||
VideoProxy::VideoProxy() {
|
||||
|
@ -81,11 +83,22 @@ bool VideoProxy::readData(void* data, size_t length, bool block) {
|
|||
}
|
||||
|
||||
void VideoProxy::postEvent(enum mVideoLoggerEvent event) {
|
||||
emit eventPosted(event);
|
||||
if (QThread::currentThread() == thread()) {
|
||||
// We're on the main thread
|
||||
emit eventPosted(event);
|
||||
} else {
|
||||
m_mutex.lock();
|
||||
emit eventPosted(event);
|
||||
m_fromThreadCond.wait(&m_mutex, 1);
|
||||
m_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void VideoProxy::lock() {
|
||||
|
|
Loading…
Reference in New Issue