summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-08-29 11:04:31 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-08-29 11:11:29 +0200
commitfd6453c45ec0da79f2c7794b1c94f31fd6e477d7 (patch)
treef924f74107842bd3c316f5c5c9ab5da810314c43 /modules
parent223e083d36ac1ca3f7aa46898d8870e476132f7a (diff)
Revert "Remove NOTIFICATION_ENTER_TREE when paired with NOTIFICATION_THEME_CHANGED"
This reverts commit 4b817a565cab8af648c88cfc7ab6481e86ee3625. Fixes #64988. Fixes #64997. This caused several regressions (#64988, #64997, https://github.com/godotengine/godot/issues/64997#issuecomment-1229970605) which point at a flaw in the current logic: - `Control::NOTIFICATION_ENTER_TREE` triggers a *deferred* notification with `NOTIFCATION_THEME_CHANGED` as introduced in #62845. - Some classes use their `THEME_CHANGED` to cache theme items in member variables (e.g. `style_normal`, etc.), and use those member variables in `ENTER_TREE`, `READY`, `DRAW`, etc. Since the `THEME_CHANGE` notification is now deferred, they end up accessing invalid state and this can lead to not applying theme properly (e.g. for EditorHelp) or crashing (e.g. for EditorLog or CodeEdit). So we need to go back to the drawing board and see if `THEME_CHANGED` can be called earlier so that the previous logic still works? Or can we refactor all engine code to make sure that: - `ENTER_TREE` and similar do not depend on theme properties cached in member variables. - Or `THEME_CHANGE` does trigger a general UI update to make sure that any bad theme handling in `ENTER_TREE` and co. gets fixed when `THEME_CHANGE` does arrive for the first time. But that means having a temporary invalid (and possibly still crashing) state, and doing some computations twice which might be heavy (e.g. `EditorHelp::_update_doc()`).
Diffstat (limited to 'modules')
-rw-r--r--modules/gridmap/editor/grid_map_editor_plugin.cpp13
-rw-r--r--modules/gridmap/editor/grid_map_editor_plugin.h1
-rw-r--r--modules/openxr/editor/openxr_action_editor.cpp7
-rw-r--r--modules/openxr/editor/openxr_action_editor.h1
-rw-r--r--modules/openxr/editor/openxr_action_map_editor.cpp1
-rw-r--r--modules/openxr/editor/openxr_action_set_editor.cpp11
-rw-r--r--modules/openxr/editor/openxr_action_set_editor.h1
-rw-r--r--modules/openxr/editor/openxr_select_action_dialog.cpp1
-rw-r--r--modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp1
9 files changed, 29 insertions, 8 deletions
diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp
index b0f73a98c9..17f9832096 100644
--- a/modules/gridmap/editor/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp
@@ -1011,6 +1011,13 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) {
}
}
+void GridMapEditor::_update_theme() {
+ options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons")));
+ search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+ mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
+ mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
+}
+
void GridMapEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -1031,6 +1038,7 @@ void GridMapEditor::_notification(int p_what) {
_update_selection_transform();
_update_paste_indicator();
+ _update_theme();
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -1071,10 +1079,7 @@ void GridMapEditor::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
- options->set_icon(get_theme_icon(SNAME("GridMap"), SNAME("EditorIcons")));
- search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
- mode_thumbnail->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")));
- mode_list->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")));
+ _update_theme();
} break;
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
diff --git a/modules/gridmap/editor/grid_map_editor_plugin.h b/modules/gridmap/editor/grid_map_editor_plugin.h
index 773bf4b6a4..a64dc4a80b 100644
--- a/modules/gridmap/editor/grid_map_editor_plugin.h
+++ b/modules/gridmap/editor/grid_map_editor_plugin.h
@@ -193,6 +193,7 @@ class GridMapEditor : public VBoxContainer {
void _item_selected_cbk(int idx);
void _update_cursor_transform();
void _update_cursor_instance();
+ void _update_theme();
void _text_changed(const String &p_text);
void _sbox_input(const Ref<InputEvent> &p_ie);
diff --git a/modules/openxr/editor/openxr_action_editor.cpp b/modules/openxr/editor/openxr_action_editor.cpp
index c4789d501f..52216fa483 100644
--- a/modules/openxr/editor/openxr_action_editor.cpp
+++ b/modules/openxr/editor/openxr_action_editor.cpp
@@ -34,10 +34,15 @@ void OpenXRActionEditor::_bind_methods() {
ADD_SIGNAL(MethodInfo("remove", PropertyInfo(Variant::OBJECT, "action_editor")));
}
+void OpenXRActionEditor::_theme_changed() {
+ rem_action->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+}
+
void OpenXRActionEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- rem_action->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ _theme_changed();
} break;
}
}
diff --git a/modules/openxr/editor/openxr_action_editor.h b/modules/openxr/editor/openxr_action_editor.h
index 2667268e9a..6cf098cf08 100644
--- a/modules/openxr/editor/openxr_action_editor.h
+++ b/modules/openxr/editor/openxr_action_editor.h
@@ -49,6 +49,7 @@ private:
OptionButton *action_type = nullptr;
Button *rem_action = nullptr;
+ void _theme_changed();
void _on_action_name_changed(const String p_new_text);
void _on_action_localized_name_changed(const String p_new_text);
void _on_item_selected(int p_idx);
diff --git a/modules/openxr/editor/openxr_action_map_editor.cpp b/modules/openxr/editor/openxr_action_map_editor.cpp
index 6be04d8119..fcbe4d57f6 100644
--- a/modules/openxr/editor/openxr_action_map_editor.cpp
+++ b/modules/openxr/editor/openxr_action_map_editor.cpp
@@ -52,6 +52,7 @@ void OpenXRActionMapEditor::_bind_methods() {
void OpenXRActionMapEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < tabs->get_child_count(); i++) {
Control *tab = static_cast<Control *>(tabs->get_child(i));
diff --git a/modules/openxr/editor/openxr_action_set_editor.cpp b/modules/openxr/editor/openxr_action_set_editor.cpp
index 6f70a91cfd..804808a6b9 100644
--- a/modules/openxr/editor/openxr_action_set_editor.cpp
+++ b/modules/openxr/editor/openxr_action_set_editor.cpp
@@ -44,12 +44,17 @@ void OpenXRActionSetEditor::_set_fold_icon() {
}
}
+void OpenXRActionSetEditor::_theme_changed() {
+ _set_fold_icon();
+ add_action->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+}
+
void OpenXRActionSetEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
- _set_fold_icon();
- add_action->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
- rem_action_set->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ _theme_changed();
panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
} break;
}
diff --git a/modules/openxr/editor/openxr_action_set_editor.h b/modules/openxr/editor/openxr_action_set_editor.h
index 0a9e3fe7b0..d8c85d03dd 100644
--- a/modules/openxr/editor/openxr_action_set_editor.h
+++ b/modules/openxr/editor/openxr_action_set_editor.h
@@ -61,6 +61,7 @@ private:
VBoxContainer *actions_vb = nullptr;
void _set_fold_icon();
+ void _theme_changed();
OpenXRActionEditor *_add_action_editor(Ref<OpenXRAction> p_action);
void _update_actions();
diff --git a/modules/openxr/editor/openxr_select_action_dialog.cpp b/modules/openxr/editor/openxr_select_action_dialog.cpp
index 1b7423ec73..80e58044d5 100644
--- a/modules/openxr/editor/openxr_select_action_dialog.cpp
+++ b/modules/openxr/editor/openxr_select_action_dialog.cpp
@@ -37,6 +37,7 @@ void OpenXRSelectActionDialog::_bind_methods() {
void OpenXRSelectActionDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
diff --git a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
index 8c88e268e9..23b025db08 100644
--- a/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
+++ b/modules/openxr/editor/openxr_select_interaction_profile_dialog.cpp
@@ -36,6 +36,7 @@ void OpenXRSelectInteractionProfileDialog::_bind_methods() {
void OpenXRSelectInteractionProfileDialog::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;