Handle closing games a bit safer

This commit is contained in:
Jeffrey Pfau 2014-07-20 21:44:06 -07:00
parent a77f7f0be2
commit a57f911ecc
1 changed files with 3 additions and 3 deletions

View File

@ -92,7 +92,7 @@ void GameController::loadGame(const QString& path) {
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 @@ void GameController::loadGame(const QString& path) {
}
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 @@ void GameController::closeGame() {
if (m_rom) {
m_rom->close();
delete m_rom;
m_rom = nullptr;
}
emit gameStopped(&m_threadContext);
}