RMG: fix 'open_rom(): not a valid ROM image' error showing up sometimes

This commit is contained in:
Rosalie Wanders committed 2023-08-27 19:49:48 +02:00
1 parent 0e2a1ba3d9
commit 9e827f97f2
3 files changed
+21 -13

No files matched your search

+14 -8
View File
@@ -49,7 +49,7 @@ MainWindow::~MainWindow()
{
}
bool MainWindow::Init(QApplication* app, bool showUI)
bool MainWindow::Init(QApplication* app, bool showUI, bool launchROM)
{
if (!CoreInit())
{
@@ -64,7 +64,7 @@ bool MainWindow::Init(QApplication* app, bool showUI)
this->configureTheme(app);
this->initializeUI();
this->initializeUI(launchROM);
this->initializeActions();
this->configureUI(app, showUI);
@@ -117,8 +117,8 @@ void MainWindow::OpenROM(QString file, QString disk, bool fullscreen, bool quitA
// if we just ensure the UI is in an emulation
// state, then the transition will be smoother
this->updateUI(true, false);
this->launchEmulationThread(file, disk);
this->launchEmulationThread(file, disk, true);
}
void MainWindow::closeEvent(QCloseEvent *event)
@@ -156,7 +156,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event);
}
void MainWindow::initializeUI(void)
void MainWindow::initializeUI(bool launchROM)
{
this->setupUi(this);
@@ -168,7 +168,13 @@ void MainWindow::initializeUI(void)
this->ui_StatusBar_Label = new QLabel(this);
this->ui_StatusBar_RenderModeLabel = new QLabel(this);
this->ui_Widget_RomBrowser->RefreshRomList();
// only start refreshing the ROM browser
// when RMG isn't launched with a ROM
// specified on the commandline
if (!launchROM)
{
this->ui_Widget_RomBrowser->RefreshRomList();
}
connect(this->ui_Widget_RomBrowser, &Widget::RomBrowserWidget::PlayGame, this,
&MainWindow::on_RomBrowser_PlayGame);
@@ -521,7 +527,7 @@ void MainWindow::connectEmulationThreadSignals(void)
Qt::BlockingQueuedConnection);
}
void MainWindow::launchEmulationThread(QString cartRom, QString diskRom)
void MainWindow::launchEmulationThread(QString cartRom, QString diskRom, bool onStartup)
{
CoreSettingsSave();
@@ -535,7 +541,7 @@ void MainWindow::launchEmulationThread(QString cartRom, QString diskRom)
}
}
this->ui_RefreshRomListAfterEmulation = this->ui_Widget_RomBrowser->IsRefreshingRomList();
this->ui_RefreshRomListAfterEmulation = onStartup || this->ui_Widget_RomBrowser->IsRefreshingRomList();
if (this->ui_RefreshRomListAfterEmulation)
{
this->ui_Widget_RomBrowser->StopRefreshRomList();
+3 -3
View File
@@ -48,7 +48,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
MainWindow(void);
~MainWindow(void);
bool Init(QApplication* app, bool showUI);
bool Init(QApplication* app, bool showUI, bool launchROM);
void OpenROM(QString file, QString disk, bool fullscreen, bool quitAfterEmulation);
private:
@@ -113,7 +113,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE;
void initializeUI();
void initializeUI(bool launchROM);
void configureUI(QApplication* app, bool showUI);
void configureTheme(QApplication* app);
@@ -127,7 +127,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
void initializeEmulationThread(void);
void connectEmulationThreadSignals(void);
void launchEmulationThread(QString cartRom, QString diskRom = "");
void launchEmulationThread(QString cartRom, QString diskRom = "", bool onStartup = false);
QString getSaveStateSlotDateTimeText(QAction* action);
QString getSaveStateSlotText(QAction* action, int slot);
+4 -2
View File
@@ -209,13 +209,15 @@ int main(int argc, char **argv)
// print debug callbacks to stdout if needed
CoreSetPrintDebugCallback(parser.isSet(debugMessagesOption));
// specified ROM path to launch
QStringList args = parser.positionalArguments();
// initialize window
if (!window.Init(&app, !parser.isSet(noGuiOption)))
if (!window.Init(&app, !parser.isSet(noGuiOption), !args.empty()))
{
return 1;
}
QStringList args = parser.positionalArguments();
if (!args.empty())
{
window.OpenROM(args.at(0), parser.value(diskOption), parser.isSet(fullscreenOption), parser.isSet(quitAfterEmulationOption));