From ccff2f2551c5749e1c7d2976222013f582d767b1 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Wed, 20 Nov 2019 10:09:59 +0100 Subject: Optimized ScriptEditor initialization when many scripts are loaded This change avoids the editor to freeze for several seconds when a project with lots of scripts is loaded in the editor. It focuses on a few heavy operations previously executed on all previously loaded scripts: - Initialize script resource (script validation/parsing) only on focus - ScriptTextEditor: code editor and edit menu are added to the scene only on focus - Add to recent scripts only when opening new scripts (load/save scene metadata) --- editor/plugins/script_editor_plugin.cpp | 61 ++++++--- editor/plugins/script_editor_plugin.h | 1 + editor/plugins/script_text_editor.cpp | 228 +++++++++++++++++++------------- editor/plugins/script_text_editor.h | 43 +++--- editor/plugins/text_editor.cpp | 42 +++--- editor/plugins/text_editor.h | 21 ++- 6 files changed, 236 insertions(+), 160 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 4f783f4e27..f1bfd5617c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -696,7 +696,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { Node *tselected = tab_container->get_child(selected); - ScriptEditorBase *current = Object::cast_to(tab_container->get_child(selected)); + ScriptEditorBase *current = Object::cast_to(tselected); if (current) { Ref