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.
This commit is contained in:
Hugo Locurcio 2020-01-19 19:41:01 +01:00
parent 90a224c6eb
commit d72f5e0938
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
3 changed files with 3 additions and 10 deletions

View file

@ -1218,7 +1218,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) {
Ref<Theme> 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);
}

View file

@ -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);

View file

@ -109,14 +109,8 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und
const int feature_min_height = 160 * EDSCALE;
Ref<Theme> 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);