Handle closing games a bit safer
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Jul 2014 21:44:06 -0700
1 files changed,
3 insertions(+),
3 deletions(-)
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -92,7 +92,7 @@ m_threadContext.sync.audioWait = 1;
m_rom = new QFile(path); if (!m_rom->open(QIODevice::ReadOnly)) { delete m_rom; - m_rom = 0; + m_rom = nullptr; } m_pauseAfterFrame = false;@@ -103,8 +103,7 @@ GBAThreadStart(&m_threadContext);
} void GameController::closeGame() { - // TODO: Make this threadsafe - if (m_threadContext.state >= THREAD_EXITING || m_threadContext.state <= THREAD_INITIALIZED) { + if (!m_rom) { return; } GBAThreadEnd(&m_threadContext);@@ -112,6 +111,7 @@ GBAThreadJoin(&m_threadContext);
if (m_rom) { m_rom->close(); delete m_rom; + m_rom = nullptr; } emit gameStopped(&m_threadContext); }