From d72f5e0938592088d3addc817cd9d9d3c91d1ae0 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 19 Jan 2020 19:41:01 +0100 Subject: [PATCH] Only create the editor theme once This prevents the editor theme from being created twice. This speeds up the project editor and editor startup significantly; startup is now 1.3 times faster on average (tested on a debug build). RAM usage was also lowered by 7.5 MB on average. This partially addresses #35321. --- editor/editor_themes.cpp | 2 +- editor/project_manager.cpp | 3 +-- editor/rename_dialog.cpp | 8 +------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 2cacc767c8c..621f5316876 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1218,7 +1218,7 @@ Ref create_editor_theme(const Ref p_theme) { Ref create_custom_theme(const Ref p_theme) { Ref theme; - String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); + const String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); if (custom_theme != "") { theme = ResourceLoader::load(custom_theme); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index ca3431d3ec9..9bbb9bd38c4 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2419,12 +2419,11 @@ ProjectManager::ProjectManager() { FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); set_anchors_and_margins_preset(Control::PRESET_WIDE); - set_theme(create_editor_theme()); + set_theme(create_custom_theme()); gui_base = memnew(Control); add_child(gui_base); gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); - gui_base->set_theme(create_custom_theme()); Panel *panel = memnew(Panel); gui_base->add_child(panel); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index ce37b9e7f6d..32fcdab4c63 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -109,14 +109,8 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und const int feature_min_height = 160 * EDSCALE; - Ref collapse_theme = create_editor_theme(); - collapse_theme->set_icon("checked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowDown", "EditorIcons")); - collapse_theme->set_icon("unchecked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowRight", "EditorIcons")); - - CheckBox *chk_collapse_features = memnew(CheckBox); + CheckButton *chk_collapse_features = memnew(CheckButton); chk_collapse_features->set_text(TTR("Advanced Options")); - chk_collapse_features->set_theme(collapse_theme); - chk_collapse_features->set_focus_mode(FOCUS_NONE); vbc->add_child(chk_collapse_features); tabc_features = memnew(TabContainer);