Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

[Editor] Fix system theme update.

Pāvels Nadtočajevs0687b50a4c77
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 2fb514cdada..dea978d02ef 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4168,10 +4168,19 @@ void EditorNode::_check_system_theme_changed() {
}
if (system_theme_changed) {
- class_icon_cache.clear();
- _update_theme();
- _build_icon_type_cache();
- recent_scenes->reset_size();
+ EditorThemeManager::set_theme_outdated();
+
+ SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
+ if (!sml) {
+ return;
+ }
+ Node *root = sml->get_root()->get_child(0);
+ if (!root) {
+ return;
+ }
+ // Some theme related settings are updated in editor settings change handlers.
+ // Using "NOTIFICATION_EDITOR_SETTINGS_CHANGED" to simulate manual theme change from the editor settings and ensure all parts of the editor are updated correctly.
+ root->propagate_notification(EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED);
} else if (menu_type == MENU_TYPE_GLOBAL && display_server->is_dark_mode_supported() && display_server->is_dark_mode() != last_dark_mode_state) {
last_dark_mode_state = display_server->is_dark_mode();
diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp
index 99b4b9633eb..2145e5b39b3 100644
--- a/editor/themes/editor_theme_manager.cpp
+++ b/editor/themes/editor_theme_manager.cpp
@@ -735,6 +735,12 @@ bool EditorThemeManager::is_generated_theme_outdated() {
return outdated_cache;
}
+void EditorThemeManager::set_theme_outdated() {
+ callable_mp_static(&EditorThemeManager::_reset_dirty_flag).call_deferred();
+ outdated_cache_dirty = false;
+ outdated_cache = true;
+}
+
bool EditorThemeManager::is_dark_theme() {
Color base_color = EDITOR_GET("interface/theme/base_color");
return base_color.get_luminance() < 0.5;
diff --git a/editor/themes/editor_theme_manager.h b/editor/themes/editor_theme_manager.h
index fe738b42219..c680da1dd10 100644
--- a/editor/themes/editor_theme_manager.h
+++ b/editor/themes/editor_theme_manager.h
@@ -227,6 +227,7 @@ public:
static Ref<EditorTheme> generate_theme(const Ref<EditorTheme> &p_old_theme = nullptr);
static bool is_generated_theme_outdated();
+ static void set_theme_outdated();
static bool is_dark_theme();
static bool is_dark_icon_and_font();