@@ -3596,6 +3596,13 @@ void ThemeEditor::_theme_close_button_cbk() {
35963596 }
35973597}
35983598
3599+ void ThemeEditor::_scene_closed (const String &p_path) {
3600+ if (theme.is_valid () && theme->is_built_in () && theme->get_path ().get_slice (" ::" , 0 ) == p_path) {
3601+ theme = Ref<Theme>();
3602+ EditorNode::get_singleton ()->hide_unused_editors (plugin);
3603+ }
3604+ }
3605+
35993606void ThemeEditor::_add_preview_button_cbk () {
36003607 preview_scene_dialog->popup_file_dialog ();
36013608}
@@ -3679,7 +3686,10 @@ void ThemeEditor::_preview_control_picked(String p_class_name) {
36793686
36803687void ThemeEditor::_notification (int p_what) {
36813688 switch (p_what) {
3682- case NOTIFICATION_ENTER_TREE:
3689+ case NOTIFICATION_READY: {
3690+ EditorNode::get_singleton ()->connect (" scene_closed" , callable_mp (this , &ThemeEditor::_scene_closed));
3691+ } break ;
3692+
36833693 case NOTIFICATION_THEME_CHANGED: {
36843694 preview_tabs->add_theme_style_override (" tab_selected" , get_theme_stylebox (SNAME (" ThemeEditorPreviewFG" ), EditorStringName (EditorStyles)));
36853695 preview_tabs->add_theme_style_override (" tab_unselected" , get_theme_stylebox (SNAME (" ThemeEditorPreviewBG" ), EditorStringName (EditorStyles)));
@@ -3807,71 +3817,7 @@ void ThemeEditorPlugin::make_visible(bool p_visible) {
38073817}
38083818
38093819bool ThemeEditorPlugin::can_auto_hide () const {
3810- Ref<Theme> edited_theme = theme_editor->theme ;
3811- if (edited_theme.is_null ()) {
3812- return true ;
3813- }
3814-
3815- Ref<Resource> edited_resource = Ref<Resource>(InspectorDock::get_inspector_singleton ()->get_next_edited_object ());
3816- if (edited_resource.is_null ()) {
3817- return true ;
3818- }
3819-
3820- // Don't hide if edited resource used by this theme.
3821- Ref<StyleBox> sbox = edited_resource;
3822- if (sbox.is_valid ()) {
3823- List<StringName> type_list;
3824- edited_theme->get_stylebox_type_list (&type_list);
3825-
3826- for (const StringName &E : type_list) {
3827- List<StringName> list;
3828- edited_theme->get_stylebox_list (E, &list);
3829-
3830- for (const StringName &F : list) {
3831- if (edited_theme->get_stylebox (F, E) == sbox) {
3832- return false ;
3833- }
3834- }
3835- }
3836- return true ;
3837- }
3838-
3839- Ref<Texture2D> tex = edited_resource;
3840- if (tex.is_valid ()) {
3841- List<StringName> type_list;
3842- edited_theme->get_icon_type_list (&type_list);
3843-
3844- for (const StringName &E : type_list) {
3845- List<StringName> list;
3846- edited_theme->get_icon_list (E, &list);
3847-
3848- for (const StringName &F : list) {
3849- if (edited_theme->get_icon (F, E) == tex) {
3850- return false ;
3851- }
3852- }
3853- }
3854- return true ;
3855- }
3856-
3857- Ref<Font> fnt = edited_resource;
3858- if (fnt.is_valid ()) {
3859- List<StringName> type_list;
3860- edited_theme->get_font_type_list (&type_list);
3861-
3862- for (const StringName &E : type_list) {
3863- List<StringName> list;
3864- edited_theme->get_font_list (E, &list);
3865-
3866- for (const StringName &F : list) {
3867- if (edited_theme->get_font (F, E) == fnt) {
3868- return false ;
3869- }
3870- }
3871- }
3872- return true ;
3873- }
3874- return true ;
3820+ return theme_editor->theme .is_null ();
38753821}
38763822
38773823ThemeEditorPlugin::ThemeEditorPlugin () {
0 commit comments