Skip to content

Commit

Permalink
Make loading translations from threads safe
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Nov 22, 2024
1 parent 9e60984 commit 7a25173
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/string/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 7a25173

Please sign in to comment.