summaryrefslogtreecommitdiffstats
path: root/core/string/translation.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-11-22 09:44:07 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-11-22 09:44:07 +0100
commit7a25173ff469b3b593cb8a5a311617c5cde9b80a (patch)
tree1510ee4bf61c99fa93c8f66f912f773862dcc81a /core/string/translation.cpp
parent9e6098432aac35bae42c9089a29ba2a80320d823 (diff)
downloadredot-engine-7a25173ff469b3b593cb8a5a311617c5cde9b80a.tar.gz
Make loading translations from threads safe
Diffstat (limited to 'core/string/translation.cpp')
-rw-r--r--core/string/translation.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 020949371f..d944135a70 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -80,8 +80,10 @@ void Translation::set_locale(const String &p_locale) {
if (Thread::is_main_thread()) {
_notify_translation_changed_if_applies();
} else {
- // Avoid calling non-thread-safe functions here.
- callable_mp(this, &Translation::_notify_translation_changed_if_applies).call_deferred();
+ // This has to happen on the main thread (bypassing the ResourceLoader per-thread call queue)
+ // because it interacts with the generally non-thread-safe window management, leading to
+ // different issues across platforms otherwise.
+ MessageQueue::get_main_singleton()->push_callable(callable_mp(this, &Translation::_notify_translation_changed_if_applies));
}
}