From 257633c354fbc8e7b5bc00c9ef5ebcf96bce3e0d Mon Sep 17 00:00:00 2001 From: Gergely Kis Date: Mon, 7 Oct 2024 13:38:29 +0200 Subject: [PATCH] Make TranslationServer singleton variable inline. This change avoids the problem known as 'Static Initialization Order Fiasco' (SIOF). See the following PR for more explanation: https://github.com/godotengine/godot/pull/94683 Co-authored-by: Gabor Koncz --- core/string/translation_server.cpp | 2 -- core/string/translation_server.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/string/translation_server.cpp b/core/string/translation_server.cpp index 89b37d0b8a2..d500d225f6b 100644 --- a/core/string/translation_server.cpp +++ b/core/string/translation_server.cpp @@ -387,8 +387,6 @@ StringName TranslationServer::translate_plural(const StringName &p_message, cons return main_domain->translate_plural(p_message, p_message_plural, p_n, p_context); } -TranslationServer *TranslationServer::singleton = nullptr; - bool TranslationServer::_load_translations(const String &p_from) { if (ProjectSettings::get_singleton()->has_setting(p_from)) { const Vector &translation_names = GLOBAL_GET(p_from); diff --git a/core/string/translation_server.h b/core/string/translation_server.h index a09230c0192..3219d6684fc 100644 --- a/core/string/translation_server.h +++ b/core/string/translation_server.h @@ -48,7 +48,7 @@ class TranslationServer : public Object { bool enabled = true; - static TranslationServer *singleton; + static inline TranslationServer *singleton = nullptr; bool _load_translations(const String &p_from); String _standardize_locale(const String &p_locale, bool p_add_defaults) const;