From 29299935750267a2d5cc58b838183df817ed7ec6 Mon Sep 17 00:00:00 2001 From: Christoph Taucher Date: Sat, 7 Oct 2023 13:05:36 +0200 Subject: [PATCH] Prevent the internal Script Editor from reloading when the external Editor is active in the settings. This prevents a crash from different race conditions from edititing files in the external editor while the internal editor tries to reload open file tabs. Some conditions that cause the crash where: * Syntax highlighting (gdscript_highlighter.cpp, syntax_highlighter.cpp) * Code analysis (code_edit.cpp) * ... and more --- editor/plugins/script_editor_plugin.cpp | 11 ++++++++--- editor/plugins/script_editor_plugin.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index c540004d3f..d6c8eef33d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -431,7 +431,7 @@ String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) { } void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) { - if (bool(EDITOR_GET("text_editor/external/use_external_editor"))) { + if (external_editor_active) { return; } @@ -2264,7 +2264,7 @@ bool ScriptEditor::edit(const Ref &p_resource, int p_line, int p_col, // Don't open dominant script if using an external editor. bool use_external_editor = - EDITOR_GET("text_editor/external/use_external_editor") || + external_editor_active || (scr.is_valid() && scr->get_language()->overrides_external_editor()); use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts. const bool open_dominant = EDITOR_GET("text_editor/behavior/files/open_dominant_script_on_scene_change"); @@ -2596,6 +2596,9 @@ void ScriptEditor::apply_scripts() const { } void ScriptEditor::reload_scripts(bool p_refresh_only) { + if (external_editor_active) { + return; + } for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to(tab_container->get_tab_control(i)); if (!se) { @@ -2763,6 +2766,7 @@ void ScriptEditor::_editor_settings_changed() { members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview"); help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index"); + external_editor_active = EDITOR_GET("text_editor/external/use_external_editor"); _update_members_overview_visibility(); _update_help_overview_visibility(); @@ -3559,7 +3563,7 @@ TypedArray ScriptEditor::_get_open_script_editors() const { void ScriptEditor::set_scene_root_script(Ref