From 31755ebb1951ccd5196291c40ff442a4e142b907 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 30c51c006..6b26e6bc8 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Emulation fixes: - GBA Memory: Make VRAM access stalls only apply to BG RAM 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: - Qt: Include wayland QPA in AppImage (fixes mgba.io/i/2796) 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() {