From a77a68bd2a14d2604be9a895567a81b66f547d23 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 4 Oct 2016 13:09:02 -0700 Subject: [PATCH] Qt: Fix crash when saving an override if a game isn't loaded --- CHANGES | 1 + src/platform/qt/GameController.cpp | 1 + src/platform/qt/OverrideView.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index b7f551ff9..f32a78486 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Bugfixes: - GBA Cheats: Fix uninitialized memory getting freed when saving - GBA Memory: Fix several unused I/O register read values - Qt: Fix patch loading + - Qt: Fix crash when saving an override if a game isn't loaded Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 9298a1eda..a96782365 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -574,6 +574,7 @@ void GameController::closeGame() { mCoreThreadUnpause(&m_threadContext); } m_patch = QString(); + clearOverride(); QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); mCoreThreadEnd(&m_threadContext); diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index 509fac5b9..249baac52 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "OverrideView.h" +#include + #include "ConfigController.h" #include "GameController.h" @@ -89,6 +91,7 @@ OverrideView::OverrideView(GameController* controller, ConfigController* config, connect(m_ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveOverride())); connect(m_ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); + m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); if (controller->isLoaded()) { gameStarted(controller->thread()); @@ -171,6 +174,7 @@ void OverrideView::gameStarted(mCoreThread* thread) { } m_ui.tabWidget->setEnabled(false); + m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true); switch (thread->core->platform(thread->core)) { #ifdef M_CORE_GBA @@ -221,6 +225,7 @@ void OverrideView::gameStopped() { m_ui.tabWidget->setEnabled(true); m_ui.savetype->setCurrentIndex(0); m_ui.idleLoop->clear(); + m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); m_ui.mbc->setCurrentIndex(0); m_ui.gbModel->setCurrentIndex(0);