summaryrefslogtreecommitdiff
path: root/editor/plugins/sprite_frames_editor_plugin.cpp
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 /editor/plugins/sprite_frames_editor_plugin.cpp
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 'editor/plugins/sprite_frames_editor_plugin.cpp')
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 56da3c986e..87f0fc4ad0 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -408,6 +408,7 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
void SpriteFramesEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")));
load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons")));