all repos — mgba @ 67e13114ef407dfe6a7cc27fc88ddcf4301a6859

mGBA Game Boy Advance Emulator

Qt: Fix some rewind timer bugs
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 May 2015 13:21:06 -0700
commit

67e13114ef407dfe6a7cc27fc88ddcf4301a6859

parent

041b58ebced4a8d4481f2c6f335a2efdf4e30dd1

2 files changed, 10 insertions(+), 3 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -46,6 +46,7 @@ , m_fpsTarget(-1)

, m_turbo(false) , m_turboForced(false) , m_turboSpeed(-1) + , m_wasPaused(false) , m_inputController(nullptr) , m_multiplayer(nullptr) , m_stateSlot(1)

@@ -351,6 +352,7 @@ void GameController::closeGame() {

if (!m_gameOpen) { return; } + m_rewindTimer.stop(); if (GBAThreadIsPaused(&m_threadContext)) { GBAThreadUnpause(&m_threadContext); }

@@ -388,7 +390,7 @@ return GBAThreadIsPaused(&m_threadContext);

} void GameController::setPaused(bool paused) { - if (!m_gameOpen || paused == GBAThreadIsPaused(&m_threadContext)) { + if (!m_gameOpen || m_rewindTimer.isActive() || paused == GBAThreadIsPaused(&m_threadContext)) { return; } if (paused) {

@@ -452,13 +454,17 @@ emit frameAvailable(m_drawContext);

} void GameController::startRewinding() { - threadInterrupt(); + if (!m_gameOpen) { + return; + } + m_wasPaused = isPaused(); + setPaused(true); m_rewindTimer.start(); } void GameController::stopRewinding() { m_rewindTimer.stop(); - threadContinue(); + setPaused(m_wasPaused); } void GameController::keyPressed(int key) {
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -187,6 +187,7 @@ bool m_turbo;

bool m_turboForced; float m_turboSpeed; QTimer m_rewindTimer; + bool m_wasPaused; int m_stateSlot;