fix ROM preloading to also go through EmuThread

This commit is contained in:
Arisotura 2024-10-24 17:48:34 +02:00
parent 1787235e09
commit 3fc065d72d
2 changed files with 16 additions and 19 deletions

View File

@ -1020,7 +1020,8 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool gbaloaded = false; bool gbaloaded = false;
if (!gbafile.isEmpty()) if (!gbafile.isEmpty())
{ {
if (!emuInstance->loadGBAROM(gbafile)) return false; if (!emuThread->insertCart(gbafile, true))
return false;
gbaloaded = true; gbaloaded = true;
} }
@ -1028,33 +1029,31 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool ndsloaded = false; bool ndsloaded = false;
if (!file.isEmpty()) 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.removeAll(file.join("|"));
recentFileList.prepend(file.join("|")); recentFileList.prepend(file.join("|"));
updateRecentFilesMenu(); updateRecentFilesMenu();
ndsloaded = true; ndsloaded = true;
} }
else if (boot)
if (boot)
{ {
if (ndsloaded) if (!emuThread->bootFirmware())
{ return false;
emuInstance->nds->Start();
emuThread->emuRun();
}
else
{
onBootFirmware();
}
} }
updateCartInserted(false); updateCartInserted(false);
if (gbaloaded) if (gbaloaded)
{
updateCartInserted(true); updateCartInserted(true);
}
return true; return true;
} }

View File

@ -250,10 +250,8 @@ bool MelonApplication::event(QEvent *event)
MainWindow* win = inst->getMainWindow(); MainWindow* win = inst->getMainWindow();
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event); QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event);
inst->getEmuThread()->emuPause();
const QStringList file = win->splitArchivePath(openEvent->file(), true); const QStringList file = win->splitArchivePath(openEvent->file(), true);
if (!win->preloadROMs(file, {}, true)) win->preloadROMs(file, {}, true);
inst->getEmuThread()->emuUnpause();
} }
return QApplication::event(event); return QApplication::event(event);