Browse Source

Merge pull request #99527 from RandomShaper/fix_threaded_trans

Make loading translations from threads safe
Thaddeus Crews 9 months ago
parent
commit
e7b11d1c99
1 changed files with 4 additions and 2 deletions
  1. 4 2
      core/string/translation.cpp

+ 4 - 2
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));
 	}
 }