Skip to content

Commit

Permalink
fix ROM preloading to also go through EmuThread
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Oct 24, 2024
1 parent 1787235 commit 3fc065d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
31 changes: 15 additions & 16 deletions src/frontend/qt_sdl/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,41 +1020,40 @@ 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;
}

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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/qt_sdl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ bool MelonApplication::event(QEvent *event)
MainWindow* win = inst->getMainWindow();
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(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);
Expand Down

0 comments on commit 3fc065d

Please sign in to comment.