Qt: Fix some rewind timer bugs
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 May 2015 13:21:06 -0700
2 files changed,
10 insertions(+),
3 deletions(-)
M
src/platform/qt/GameController.cpp
→
src/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.h
→
src/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;