From 7895d43a98f93241624d347fb744489d30e55de8 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 12 Feb 2022 12:02:03 +0100 Subject: [PATCH] Terminate headless rpcs3 if nothing was booted --- rpcs3/main.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index fe35644787..41d41c3cac 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -999,6 +999,24 @@ int main(int argc, char** argv) } }); } + else if (s_headless || s_no_gui) + { +#ifdef _WIN32 + // If launched from CMD + if (AttachConsole(ATTACH_PARENT_PROCESS)) + [[maybe_unused]] const auto con_out = freopen("CONOUT$", "w", stderr); +#endif + sys_log.error("Cannot run %s mode without boot target. Terminating...", s_headless ? "headless" : "no-gui"); + fprintf(stderr, "Cannot run %s mode without boot target. Terminating...\n", s_headless ? "headless" : "no-gui"); + + if (s_no_gui) + { + QMessageBox::warning(nullptr, QObject::tr("Missing command-line arguments!"), QObject::tr("Cannot run no-gui mode without boot target.\nTerminating...")); + } + + Emu.Quit(true); + return 0; + } // run event loop (maybe only needed for the gui application) return app->exec();