Qt: Add -testconfig option

This commit is contained in:
Connor McLaughlin 2022-11-23 21:21:20 +10:00 committed by refractionpcsx2
parent 6f354c6c02
commit edb9a5ba3c
3 changed files with 18 additions and 1 deletions

View File

@ -94,6 +94,7 @@ static bool s_batch_mode = false;
static bool s_nogui_mode = false; static bool s_nogui_mode = false;
static bool s_start_fullscreen_ui = false; static bool s_start_fullscreen_ui = false;
static bool s_start_fullscreen_ui_fullscreen = false; static bool s_start_fullscreen_ui_fullscreen = false;
static bool s_test_config_and_exit = false;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// CPU Thread // CPU Thread
@ -1604,6 +1605,7 @@ void QtHost::PrintCommandLineHelp(const std::string_view& progname)
std::fprintf(stderr, " -fullscreen: Enters fullscreen mode immediately after starting.\n"); std::fprintf(stderr, " -fullscreen: Enters fullscreen mode immediately after starting.\n");
std::fprintf(stderr, " -nofullscreen: Prevents fullscreen mode from triggering if enabled.\n"); std::fprintf(stderr, " -nofullscreen: Prevents fullscreen mode from triggering if enabled.\n");
std::fprintf(stderr, " -earlyconsolelog: Forces logging of early console messages to console.\n"); std::fprintf(stderr, " -earlyconsolelog: Forces logging of early console messages to console.\n");
std::fprintf(stderr, " -testconfig: Initializes configuration and checks version, then exits.\n");
#ifdef ENABLE_RAINTEGRATION #ifdef ENABLE_RAINTEGRATION
std::fprintf(stderr, " -raintegration: Use RAIntegration instead of built-in achievement support.\n"); std::fprintf(stderr, " -raintegration: Use RAIntegration instead of built-in achievement support.\n");
#endif #endif
@ -1721,6 +1723,11 @@ bool QtHost::ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VM
s_start_fullscreen_ui = true; s_start_fullscreen_ui = true;
continue; continue;
} }
else if (CHECK_ARG(QStringLiteral("-testconfig")))
{
s_test_config_and_exit = true;
continue;
}
#ifdef ENABLE_RAINTEGRATION #ifdef ENABLE_RAINTEGRATION
else if (CHECK_ARG(QStringLiteral("-raintegration"))) else if (CHECK_ARG(QStringLiteral("-raintegration")))
{ {
@ -1831,6 +1838,10 @@ int main(int argc, char* argv[])
if (!QtHost::InitializeConfig()) if (!QtHost::InitializeConfig())
return EXIT_FAILURE; return EXIT_FAILURE;
// Are we just setting up the configuration?
if (s_test_config_and_exit)
return EXIT_SUCCESS;
// Set theme before creating any windows. // Set theme before creating any windows.
MainWindow::updateApplicationTheme(); MainWindow::updateApplicationTheme();
MainWindow* main_window = new MainWindow(); MainWindow* main_window = new MainWindow();
@ -1873,6 +1884,10 @@ int main(int argc, char* argv[])
delete g_main_window; delete g_main_window;
} }
// Ensure config is written. Prevents destruction order issues.
if (s_base_settings_interface->IsDirty())
s_base_settings_interface->Save();
// Ensure emulog is flushed. // Ensure emulog is flushed.
if (emuLog) if (emuLog)
{ {

View File

@ -66,6 +66,7 @@ public:
~VU_Thread(); ~VU_Thread();
__fi const Threading::ThreadHandle& GetThreadHandle() const { return m_thread; } __fi const Threading::ThreadHandle& GetThreadHandle() const { return m_thread; }
__fi bool IsOpen() const { return m_thread.Joinable(); }
/// Ensures the VU thread is started. /// Ensures the VU thread is started.
void Open(); void Open();

View File

@ -381,7 +381,8 @@ void recMicroVU0::Shutdown()
} }
void recMicroVU1::Shutdown() void recMicroVU1::Shutdown()
{ {
vu1Thread.WaitVU(); if (vu1Thread.IsOpen())
vu1Thread.WaitVU();
mVUclose(microVU1); mVUclose(microVU1);
} }