as promised, reroute dropEvent() through EmuThread
Some checks failed
macOS / ${{ matrix.arch }} (arm64) (push) Has been cancelled
macOS / ${{ matrix.arch }} (x86_64) (push) Has been cancelled
macOS / Universal binary (push) Has been cancelled
Ubuntu / x86_64 (push) Has been cancelled
Ubuntu / aarch64 (push) Has been cancelled
Windows / build (push) Has been cancelled

This commit is contained in:
Arisotura 2024-10-25 16:16:23 +02:00
parent fc3c7440d1
commit 1d284f6f1e

View File

@ -920,20 +920,12 @@ void MainWindow::dropEvent(QDropEvent* event)
QList<QUrl> urls = event->mimeData()->urls(); QList<QUrl> urls = event->mimeData()->urls();
if (urls.count() > 1) return; // not handling more than one file at once if (urls.count() > 1) return; // not handling more than one file at once
emuThread->emuPause();
if (!verifySetup()) if (!verifySetup())
{
emuThread->emuUnpause();
return; return;
}
const QStringList file = splitArchivePath(urls.at(0).toLocalFile(), false); const QStringList file = splitArchivePath(urls.at(0).toLocalFile(), false);
if (file.isEmpty()) if (file.isEmpty())
{
emuThread->emuUnpause();
return; return;
}
const QString filename = file.last(); const QString filename = file.last();
const bool romInsideArchive = file.size() > 1; const bool romInsideArchive = file.size() > 1;
@ -947,9 +939,8 @@ void MainWindow::dropEvent(QDropEvent* event)
if (isNdsRom) if (isNdsRom)
{ {
if (!emuInstance->loadROM(file, true)) if (!emuThread->bootROM(file))
{ {
emuThread->emuUnpause();
return; return;
} }
@ -958,28 +949,20 @@ void MainWindow::dropEvent(QDropEvent* event)
recentFileList.prepend(barredFilename); recentFileList.prepend(barredFilename);
updateRecentFilesMenu(); updateRecentFilesMenu();
assert(emuInstance->nds != nullptr);
emuInstance->nds->Start();
emuThread->emuRun();
updateCartInserted(false); updateCartInserted(false);
} }
else if (isGbaRom) else if (isGbaRom)
{ {
if (!emuInstance->loadGBAROM(file)) if (!emuThread->insertCart(file, true))
{ {
emuThread->emuUnpause();
return; return;
} }
emuThread->emuUnpause();
updateCartInserted(true); updateCartInserted(true);
} }
else else
{ {
QMessageBox::critical(this, "melonDS", "The file could not be recognized as a DS or GBA ROM."); QMessageBox::critical(this, "melonDS", "The file could not be recognized as a DS or GBA ROM.");
emuThread->emuUnpause();
return; return;
} }
} }