From a6ff9f6c60e2b745a2e27323bf89bc4d2d08005e Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 3 Aug 2015 23:52:18 -0700 Subject: [PATCH] Qt: Fix frame delay with pausing and frame advancing --- src/platform/qt/GameController.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 7c655fb96..d1d73f5f3 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -121,15 +121,15 @@ GameController::GameController(QObject* parent) m_threadContext.frameCallback = [](GBAThread* context) { GameController* controller = static_cast(context->userData); - if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) { - GBAThreadPauseFromThread(context); - controller->gamePaused(&controller->m_threadContext); - } if (GBASyncDrawingFrame(&controller->m_threadContext.sync)) { controller->frameAvailable(controller->m_drawContext); } else { controller->frameAvailable(nullptr); } + if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) { + GBAThreadPauseFromThread(context); + controller->gamePaused(&controller->m_threadContext); + } }; m_threadContext.stopCallback = [](GBAThread* context) { @@ -464,8 +464,7 @@ void GameController::setPaused(bool paused) { return; } if (paused) { - GBAThreadPause(&m_threadContext); - emit gamePaused(&m_threadContext); + m_pauseAfterFrame.testAndSetRelaxed(false, true); } else { GBAThreadUnpause(&m_threadContext); emit gameUnpaused(&m_threadContext);