all repos — mgba @ a57f911eccd740d3dbc5581cd766cee65f43dee1

mGBA Game Boy Advance Emulator

Handle closing games a bit safer
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Jul 2014 21:44:06 -0700
commit

a57f911eccd740d3dbc5581cd766cee65f43dee1

parent

a77f7f0be23b333891bba627730d47f5b9e23d25

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/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); }