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 <gabor.koncz@migeran.com>
This commit is contained in:
Gergely Kis 2024-10-07 13:38:29 +02:00
parent db66bd35af
commit 257633c354
2 changed files with 1 additions and 3 deletions

View File

@ -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<String> &translation_names = GLOBAL_GET(p_from);

View File

@ -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;