diff options
author | rsjtdrjgfuzkfg <public@rsjtdrjgfuzkfg.com> | 2023-02-16 20:41:51 +0100 |
---|---|---|
committer | rsjtdrjgfuzkfg <public@rsjtdrjgfuzkfg.com> | 2023-02-16 20:41:51 +0100 |
commit | 331dd33009289915619bb1ab7d76d156d951183a (patch) | |
tree | 1abc926b0dc9d300b6a948fcd8ea335e7886b09e | |
parent | 29f670b7ab28d6393b0a61d6860decc69c2dc1ec (diff) |
Theme Editor: fix leading styleboxes / main styles
Recent changes in Godot cause the theme editor to become hidden when
editing a child resource. This causes a crash when editing style box
resources marked as "main styles" (= leading styleboxes in the code), as
they try to reference the currently edited theme.
This commit works around the issue by permitting the Theme Editor to
keep a reference to the most recently edited Theme. Furthermore, it adds
an assertion to avoid a similar crash in the future.
Long-term, the workaround should probably be removed when the theme editor
is fixed to remain visible while editing child resources, but I'd keep
the assertion.
-rw-r--r-- | editor/plugins/theme_editor_plugin.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 073adb467a..2519928ea3 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -3223,6 +3223,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { if (!leading_stylebox.pinned || leading_stylebox.stylebox.is_null()) { return; } + ERR_FAIL_COND_MSG(edited_theme.is_null(), "Leading stylebox does not have an edited theme to update"); // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); @@ -3706,7 +3707,11 @@ void ThemeEditorPlugin::edit(Object *p_node) { if (Object::cast_to<Theme>(p_node)) { theme_editor->edit(Object::cast_to<Theme>(p_node)); } else { - theme_editor->edit(Ref<Theme>()); + // We intentionally keep a reference to the last used theme to work around + // the the editor being hidden while base resources are edited. Uncomment + // the following line again and remove this comment once that bug has been + // fixed (scheduled for Godot 4.1 in PR 73098): + // theme_editor->edit(Ref<Theme>()); } } |