summaryrefslogtreecommitdiffstats
path: root/scene/main/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/window.cpp')
-rw-r--r--scene/main/window.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index c79ac1f40b..ba53a5e3c3 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -1269,7 +1269,9 @@ void Window::_notification(int p_what) {
notification(NOTIFICATION_TRANSLATION_CHANGED);
}
#endif
- notification(NOTIFICATION_THEME_CHANGED);
+
+ // Emits NOTIFICATION_THEME_CHANGED internally.
+ set_theme_context(ThemeDB::get_singleton()->get_nearest_theme_context(this));
} break;
case NOTIFICATION_READY: {
@@ -1313,6 +1315,8 @@ void Window::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
+ set_theme_context(nullptr, false);
+
if (transient) {
_clear_transient();
}
@@ -1889,6 +1893,11 @@ bool Window::has_theme_owner_node() const {
return theme_owner->has_owner_node();
}
+void Window::set_theme_context(ThemeContext *p_context, bool p_propagate) {
+ ERR_MAIN_THREAD_GUARD;
+ theme_owner->set_owner_context(p_context, p_propagate);
+}
+
void Window::set_theme(const Ref<Theme> &p_theme) {
ERR_MAIN_THREAD_GUARD;
if (theme == p_theme) {
@@ -2887,7 +2896,7 @@ Window::Window() {
max_size_used = max_size; // Update max_size_used.
}
- theme_owner = memnew(ThemeOwner);
+ theme_owner = memnew(ThemeOwner(this));
RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED);
}