From 3fc065d72d03112ba26b617033537e398e3fbcb2 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 24 Oct 2024 17:48:34 +0200 Subject: [PATCH] fix ROM preloading to also go through EmuThread --- src/frontend/qt_sdl/Window.cpp | 31 +++++++++++++++---------------- src/frontend/qt_sdl/main.cpp | 4 +--- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index a19b29ed..65e85f1c 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -1020,7 +1020,8 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot) bool gbaloaded = false; if (!gbafile.isEmpty()) { - if (!emuInstance->loadGBAROM(gbafile)) return false; + if (!emuThread->insertCart(gbafile, true)) + return false; gbaloaded = true; } @@ -1028,33 +1029,31 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot) bool ndsloaded = false; if (!file.isEmpty()) { - if (!emuInstance->loadROM(file, true)) return false; + if (boot) + { + if (!emuThread->bootROM(file)) + return false; + } + else + { + if (!emuThread->insertCart(file, false)) + return false; + } recentFileList.removeAll(file.join("|")); recentFileList.prepend(file.join("|")); updateRecentFilesMenu(); ndsloaded = true; } - - if (boot) + else if (boot) { - if (ndsloaded) - { - emuInstance->nds->Start(); - emuThread->emuRun(); - } - else - { - onBootFirmware(); - } + if (!emuThread->bootFirmware()) + return false; } updateCartInserted(false); - if (gbaloaded) - { updateCartInserted(true); - } return true; } diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 2643104d..6d18adaf 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -250,10 +250,8 @@ bool MelonApplication::event(QEvent *event) MainWindow* win = inst->getMainWindow(); QFileOpenEvent *openEvent = static_cast(event); - inst->getEmuThread()->emuPause(); const QStringList file = win->splitArchivePath(openEvent->file(), true); - if (!win->preloadROMs(file, {}, true)) - inst->getEmuThread()->emuUnpause(); + win->preloadROMs(file, {}, true); } return QApplication::event(event);