Skip to content

Commit 2929993

Browse files
committed
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
1 parent 6916349 commit 2929993

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

editor/plugins/script_editor_plugin.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) {
431431
}
432432

433433
void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
434-
if (bool(EDITOR_GET("text_editor/external/use_external_editor"))) {
434+
if (external_editor_active) {
435435
return;
436436
}
437437

@@ -2264,7 +2264,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
22642264

22652265
// Don't open dominant script if using an external editor.
22662266
bool use_external_editor =
2267-
EDITOR_GET("text_editor/external/use_external_editor") ||
2267+
external_editor_active ||
22682268
(scr.is_valid() && scr->get_language()->overrides_external_editor());
22692269
use_external_editor = use_external_editor && !(scr.is_valid() && scr->is_built_in()); // Ignore external editor for built-in scripts.
22702270
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 {
25962596
}
25972597

25982598
void ScriptEditor::reload_scripts(bool p_refresh_only) {
2599+
if (external_editor_active) {
2600+
return;
2601+
}
25992602
for (int i = 0; i < tab_container->get_tab_count(); i++) {
26002603
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
26012604
if (!se) {
@@ -2763,6 +2766,7 @@ void ScriptEditor::_editor_settings_changed() {
27632766

27642767
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
27652768
help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index");
2769+
external_editor_active = EDITOR_GET("text_editor/external/use_external_editor");
27662770
_update_members_overview_visibility();
27672771
_update_help_overview_visibility();
27682772

@@ -3559,7 +3563,7 @@ TypedArray<ScriptEditorBase> ScriptEditor::_get_open_script_editors() const {
35593563
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
35603564
// Don't open dominant script if using an external editor.
35613565
bool use_external_editor =
3562-
EDITOR_GET("text_editor/external/use_external_editor") ||
3566+
external_editor_active ||
35633567
(p_script.is_valid() && p_script->get_language()->overrides_external_editor());
35643568
use_external_editor = use_external_editor && !(p_script.is_valid() && p_script->is_built_in()); // Ignore external editor for built-in scripts.
35653569
const bool open_dominant = EDITOR_GET("text_editor/behavior/files/open_dominant_script_on_scene_change");
@@ -3827,6 +3831,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
38273831
waiting_update_names = false;
38283832
pending_auto_reload = false;
38293833
auto_reload_running_scripts = true;
3834+
external_editor_active = false;
38303835
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
38313836
help_overview_enabled = EDITOR_GET("text_editor/help/show_help_index");
38323837

editor/plugins/script_editor_plugin.h

+1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class ScriptEditor : public PanelContainer {
396396
bool open_textfile_after_create = true;
397397
bool trim_trailing_whitespace_on_save;
398398
bool convert_indent_on_save;
399+
bool external_editor_active;
399400

400401
void _goto_script_line2(int p_line);
401402
void _goto_script_line(Ref<RefCounted> p_script, int p_line);

0 commit comments

Comments
 (0)