From 6d8060034f3471de2a98d90a0e9a5d7b93d410b1 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 27 Jan 2023 19:32:27 -0800 Subject: [PATCH] Qt: Disable sync while running scripts from main thread (fixes #2738) --- CHANGES | 1 + src/platform/qt/scripting/ScriptingController.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 4803ef370..9b971cbe8 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Emulation fixes: - GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722) Other fixes: - Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794) + - Qt: Disable sync while running scripts from main thread (fixes mgba.io/i/2738) Misc: - GB Serialize: Add missing savestate support for MBC6 and NT (newer) - GBA: Improve detection of valid ELF ROMs diff --git a/src/platform/qt/scripting/ScriptingController.cpp b/src/platform/qt/scripting/ScriptingController.cpp index cd1e716d4..5e92a81aa 100644 --- a/src/platform/qt/scripting/ScriptingController.cpp +++ b/src/platform/qt/scripting/ScriptingController.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "scripting/ScriptingController.h" +#include "AudioProcessor.h" #include "CoreController.h" #include "scripting/ScriptingTextBuffer.h" #include "scripting/ScriptingTextBufferModel.h" @@ -73,11 +74,20 @@ bool ScriptingController::load(VFileDevice& vf, const QString& name) { } QByteArray utf8 = name.toUtf8(); CoreController::Interrupter interrupter(m_controller); + if (m_controller) { + m_controller->setSync(false); + m_controller->unpaused(); + } + bool ok = true; if (!m_activeEngine->load(m_activeEngine, utf8.constData(), vf) || !m_activeEngine->run(m_activeEngine)) { emit error(QString::fromUtf8(m_activeEngine->getError(m_activeEngine))); - return false; + ok = false; } - return true; + if (m_controller && m_controller->isPaused()) { + m_controller->setSync(true); + m_controller->paused(); + } + return ok; } void ScriptingController::clearController() {