From ce727b71fb326947e1079ca8540e734712693ba1 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 10 Apr 2026 16:45:51 -0600 Subject: [PATCH] Avoid re-initializing game_main --- src/dusk/config.cpp | 4 ++-- src/m_Do/m_Do_main.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dusk/config.cpp b/src/dusk/config.cpp index 159706fac8..98f32cf8cd 100644 --- a/src/dusk/config.cpp +++ b/src/dusk/config.cpp @@ -20,7 +20,7 @@ using json = nlohmann::json; aurora::Module DuskConfigLog("dusk::config"); static absl::flat_hash_map RegisteredConfigVars; -static bool RegistrationDone; +static bool RegistrationDone = false; static std::string GetConfigJsonPath() { return fmt::format("{}{}", configPath, ConfigFileName); @@ -219,4 +219,4 @@ ConfigVarBase* dusk::config::GetConfigVar(std::string_view name) { } return nullptr; -} \ No newline at end of file +} diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index e82f6cd8ba..b5f5e36669 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -366,10 +366,19 @@ static constexpr PADDefaultMapping defaultPadMapping = { }, }; +static bool mainCalled = false; + // ========================================================================= // PC ENTRY POINT // ========================================================================= int game_main(int argc, char* argv[]) { + // On iOS, when connected to an external monitor, SDLUIKitSceneDelegate scene:willConnectToSession: + // can call our main function again. Explicitly guard against this reinitialization. + if (mainCalled) { + return 0; + } + mainCalled = true; + dusk::registerSettings(); dusk::config::FinishRegistration();