diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 35870b6569..eb940f8689 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -774,24 +774,28 @@ int main(int argc, char** argv) // Force install firmware first if specified through command-line if (parser.isSet(arg_installfw)) { - firmware_path = parser.value(installfw_option).toStdString(); - if (!fs::is_file(firmware_path)) + if (auto gui_app = qobject_cast(app.data())) { - report_fatal_error(fmt::format("No firmware file found: %s", firmware_path)); - return 1; + if (s_no_gui) + { + report_fatal_error("Cannot install firmware in no-gui mode!"); + return 1; + } + + if (gui_app->m_main_window) + { + gui_app->m_main_window->HandlePupInstallation(parser.value(installfw_option)); + } + else + { + report_fatal_error("Cannot install firmware. No main window found!"); + return 1; + } } else { - if (auto gui_app = qobject_cast(app.data())) - { - main_window* main_window = gui_app->m_main_window; - if (!main_window) - { - report_fatal_error("Cannot install firmware, exiting !"); - return 1; - } - main_window->HandlePupInstallation(QString::fromStdString(firmware_path)); - } + report_fatal_error("Cannot install firmware in headless mode!"); + return 1; } } @@ -800,7 +804,7 @@ int main(int argc, char** argv) sys_log.notice("Option passed via command line: %s %s", opt.toStdString(), parser.value(opt).toStdString()); } - if (const QStringList args = parser.positionalArguments(); !args.isEmpty() && !is_updating) + if (const QStringList args = parser.positionalArguments(); !args.isEmpty() && !is_updating && !parser.isSet(arg_installfw)) { sys_log.notice("Booting application from command line: %s", args.at(0).toStdString()); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 1ff7220dd3..921cc004e2 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -918,8 +918,18 @@ void main_window::ExtractTar() void main_window::HandlePupInstallation(QString file_path, QString dir_path) { + const auto critical = [this](QString str) + { + Emu.CallAfter([this, str = std::move(str)]() + { + QMessageBox::critical(this, tr("Firmware Installation Failed"), str); + }, false); + }; + if (file_path.isEmpty()) { + gui_log.error("Error while installing firmware: provided path is empty."); + critical(tr("Firmware installation failed: The provided path is empty.")); return; } @@ -935,14 +945,6 @@ void main_window::HandlePupInstallation(QString file_path, QString dir_path) const std::string path = sstr(file_path); - auto critical = [this](QString str) - { - Emu.CallAfter([this, str = std::move(str)]() - { - QMessageBox::critical(this, tr("Firmware Installation Failed"), str); - }, false); - }; - fs::file pup_f(path); if (!pup_f) {