From dabad822193f23bd01c13c4d0798f0a507e910eb Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 25 Jun 2022 17:31:31 +0200 Subject: Require frontend to initialize controllers We currently have two different code paths for initializing controllers: Either the frontend (DolphinQt) can do it, or if the frontend doesn't do it, the core will do it automatically when booting. Having these two paths has caused problems in the past due to only one frontend being tested (see de7ef47548). I would like to get rid of the latter path to avoid further problems like this. --- Source/Core/DolphinNoGUI/MainNoGUI.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Source/Core/DolphinNoGUI/MainNoGUI.cpp') diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index cec4788f1c..03ea30ec17 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -17,6 +17,7 @@ #include #endif +#include "Common/ScopeGuard.h" #include "Common/StringUtil.h" #include "Core/Boot/Boot.h" #include "Core/BootManager.h" @@ -226,10 +227,6 @@ int main(int argc, char* argv[]) if (options.is_set("user")) user_directory = static_cast(options.get("user")); - UICommon::SetUserDirectory(user_directory); - UICommon::Init(); - GCAdapter::Init(); - s_platform = GetPlatform(options); if (!s_platform || !s_platform->Init()) { @@ -237,6 +234,17 @@ int main(int argc, char* argv[]) return 1; } + const WindowSystemInfo wsi = s_platform->GetWindowSystemInfo(); + + UICommon::SetUserDirectory(user_directory); + UICommon::Init(); + UICommon::InitControllers(wsi); + + Common::ScopeGuard ui_common_guard([] { + UICommon::ShutdownControllers(); + UICommon::Shutdown(); + }); + if (save_state_path && !game_specified) { fprintf(stderr, "A save state cannot be loaded without specifying a game to launch.\n"); @@ -263,7 +271,7 @@ int main(int argc, char* argv[]) DolphinAnalytics::Instance().ReportDolphinStart("nogui"); - if (!BootManager::BootCore(std::move(boot), s_platform->GetWindowSystemInfo())) + if (!BootManager::BootCore(std::move(boot), wsi)) { fprintf(stderr, "Could not boot the specified file\n"); return 1; @@ -278,7 +286,6 @@ int main(int argc, char* argv[]) Core::Shutdown(); s_platform.reset(); - UICommon::Shutdown(); return 0; } -- cgit v1.2.3