diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index bbdb86cb4..85cb75c05 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -42,6 +42,7 @@ void Display::startDrawing(const uint32_t* buffer, GBAThread* thread) { m_painter->setContext(thread); m_painter->setBacking(buffer); m_painter->moveToThread(m_drawThread); + m_context = thread; doneCurrent(); context()->moveToThread(m_drawThread); connect(m_drawThread, SIGNAL(started()), m_painter, SLOT(start())); @@ -50,9 +51,13 @@ void Display::startDrawing(const uint32_t* buffer, GBAThread* thread) { void Display::stopDrawing() { if (m_drawThread) { + GBAThreadInterrupt(m_context); + GBASyncSuspendDrawing(&m_context->sync); QMetaObject::invokeMethod(m_painter, "stop", Qt::BlockingQueuedConnection); m_drawThread->exit(); m_drawThread = nullptr; + GBASyncResumeDrawing(&m_context->sync); + GBAThreadContinue(m_context); } } @@ -70,7 +75,11 @@ void Display::initializeGL() { void Display::resizeEvent(QResizeEvent* event) { if (m_drawThread) { + GBAThreadInterrupt(m_context); + GBASyncSuspendDrawing(&m_context->sync); QMetaObject::invokeMethod(m_painter, "resize", Qt::BlockingQueuedConnection, Q_ARG(QSize, event->size())); + GBASyncResumeDrawing(&m_context->sync); + GBAThreadContinue(m_context); } } diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 87082c2de..15929ce5e 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -29,6 +29,7 @@ protected: private: Painter* m_painter; QThread* m_drawThread; + GBAThread* m_context; }; class Painter : public QObject { diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 8edf0b533..4256a3db2 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -215,7 +215,6 @@ void GameController::setFPSTarget(float fps) { void GameController::loadState(int slot) { GBAThreadInterrupt(&m_threadContext); GBALoadState(m_threadContext.gba, m_threadContext.stateDir, slot); - ConditionWake(&m_threadContext.sync.videoFrameAvailableCond); // Hack: wake up the drawing thread GBAThreadContinue(&m_threadContext); emit stateLoaded(&m_threadContext); emit frameAvailable(m_drawContext);