You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #106855 from timothyqiu/control-through-stillness
Don't update scene tree when calling `Translation::set_locale()`
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
|
|
||||||
#include "core/os/os.h"
|
|
||||||
#include "core/os/thread.h"
|
#include "core/os/thread.h"
|
||||||
#include "core/string/translation_server.h"
|
#include "core/string/translation_server.h"
|
||||||
|
|
||||||
@@ -74,21 +73,6 @@ void Translation::_set_messages(const Dictionary &p_messages) {
|
|||||||
|
|
||||||
void Translation::set_locale(const String &p_locale) {
|
void Translation::set_locale(const String &p_locale) {
|
||||||
locale = TranslationServer::get_singleton()->standardize_locale(p_locale);
|
locale = TranslationServer::get_singleton()->standardize_locale(p_locale);
|
||||||
|
|
||||||
if (Thread::is_main_thread()) {
|
|
||||||
_notify_translation_changed_if_applies();
|
|
||||||
} else {
|
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Translation::_notify_translation_changed_if_applies() {
|
|
||||||
if (OS::get_singleton()->get_main_loop() && TranslationServer::get_singleton()->get_loaded_locales().has(get_locale())) {
|
|
||||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Translation::add_message(const StringName &p_src_text, const StringName &p_xlated_text, const StringName &p_context) {
|
void Translation::add_message(const StringName &p_src_text, const StringName &p_xlated_text, const StringName &p_context) {
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ class Translation : public Resource {
|
|||||||
virtual Dictionary _get_messages() const;
|
virtual Dictionary _get_messages() const;
|
||||||
virtual void _set_messages(const Dictionary &p_messages);
|
virtual void _set_messages(const Dictionary &p_messages);
|
||||||
|
|
||||||
void _notify_translation_changed_if_applies();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user