aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/Window.cpp
diff options
context:
space:
mode:
authorJaklyy <102590697+Jaklyy@users.noreply.github.com>2024-02-07 17:04:36 -0500
committerGitHub <noreply@github.com>2024-02-07 23:04:36 +0100
commit5ffa6429804a5668edf198a26a1595c170149798 (patch)
treec8265c1d9d975ef525848c8d5977998b763f191d /src/frontend/qt_sdl/Window.cpp
parent71e1ba8c40468385f2e66142cdbc943c4efb8f55 (diff)
Check for write permissions for some key files (#1972)
* check if an nds save file can be opened for writing also add the ability to open a file in append mode * fix multi-instance saves also move the check for file writability into a separate function (probably uneeded?) * implement check for gba roms * move rom load error messages into the functions also finish gba slot (oops) * improve error string * check write perms before saving path settings * fix memory leak * check for writability of firmware/nand/sds * add secondary checks for nand/firmware * add check for config file being writable * Return the file write error as a QString to avoid the invalid char* causing a garbled error message. Qt wants it as QString either way.
Diffstat (limited to 'src/frontend/qt_sdl/Window.cpp')
-rw-r--r--src/frontend/qt_sdl/Window.cpp43
1 files changed, 11 insertions, 32 deletions
diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp
index 962fb76..0f0b71f 100644
--- a/src/frontend/qt_sdl/Window.cpp
+++ b/src/frontend/qt_sdl/Window.cpp
@@ -865,10 +865,8 @@ void MainWindow::dropEvent(QDropEvent* event)
if (isNdsRom)
{
- if (!ROMManager::LoadROM(emuThread, file, true))
+ if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the DS ROM.");
emuThread->emuUnpause();
return;
}
@@ -886,10 +884,8 @@ void MainWindow::dropEvent(QDropEvent* event)
}
else if (isGbaRom)
{
- if (!ROMManager::LoadGBAROM(*emuThread->NDS, file))
+ if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the GBA ROM.");
emuThread->emuUnpause();
return;
}
@@ -952,12 +948,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool gbaloaded = false;
if (!gbafile.isEmpty())
{
- if (!ROMManager::LoadGBAROM(*emuThread->NDS, gbafile))
- {
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the GBA ROM.");
- return false;
- }
+ if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, gbafile)) return false;
gbaloaded = true;
}
@@ -965,12 +956,8 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool ndsloaded = false;
if (!file.isEmpty())
{
- if (!ROMManager::LoadROM(emuThread, file, true))
- {
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
- return false;
- }
+ if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) return false;
+
recentFileList.removeAll(file.join("|"));
recentFileList.prepend(file.join("|"));
updateRecentFilesMenu();
@@ -1173,11 +1160,9 @@ void MainWindow::onOpenFile()
emuThread->emuUnpause();
return;
}
-
- if (!ROMManager::LoadROM(emuThread, file, true))
+
+ if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
emuThread->emuUnpause();
return;
}
@@ -1272,11 +1257,9 @@ void MainWindow::onClickRecentFile()
emuThread->emuUnpause();
return;
}
-
- if (!ROMManager::LoadROM(emuThread, file, true))
+
+ if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
emuThread->emuUnpause();
return;
}
@@ -1326,10 +1309,8 @@ void MainWindow::onInsertCart()
return;
}
- if (!ROMManager::LoadROM(emuThread, file, false))
+ if (!ROMManager::LoadROM(mainWindow, emuThread, file, false))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
emuThread->emuUnpause();
return;
}
@@ -1361,10 +1342,8 @@ void MainWindow::onInsertGBACart()
return;
}
- if (!ROMManager::LoadGBAROM(*emuThread->NDS, file))
+ if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file))
{
- // TODO: better error reporting?
- QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
emuThread->emuUnpause();
return;
}