From bc56681b0b71ee3f620fdb6f36e9daeebdea584a Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 4 Mar 2021 01:04:31 +0100 Subject: [PATCH] Don't save unchanged script upon closing (cherry picked from commit 12f5a5a701bf852bbee8ab785205c90f8ad710ca) --- editor/plugins/script_editor_plugin.cpp | 13 ++++++------- editor/plugins/script_editor_plugin.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index e5c93d1bd0d..ca3f76b882b 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -639,9 +639,8 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { _save_layout(); } -void ScriptEditor::_close_current_tab() { - - _close_tab(tab_container->get_current_tab()); +void ScriptEditor::_close_current_tab(bool p_save) { + _close_tab(tab_container->get_current_tab(), p_save); } void ScriptEditor::_close_discard_current_tab(const String &p_str) { @@ -692,7 +691,7 @@ void ScriptEditor::_close_other_tabs() { } } - _close_current_tab(); + _close_current_tab(false); } } @@ -713,7 +712,7 @@ void ScriptEditor::_close_all_tabs() { } } - _close_current_tab(); + _close_current_tab(false); } } @@ -1260,7 +1259,7 @@ void ScriptEditor::_menu_option(int p_option) { if (current->is_unsaved()) { _ask_close_current_unsaved_tab(current); } else { - _close_current_tab(); + _close_current_tab(false); } } break; case FILE_COPY_PATH: { @@ -3467,7 +3466,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm->get_ok()->set_text(TTR("Save")); erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard"); - erase_tab_confirm->connect("confirmed", this, "_close_current_tab"); + erase_tab_confirm->connect("confirmed", this, "_close_current_tab", varray(true)); erase_tab_confirm->connect("custom_action", this, "_close_discard_current_tab"); add_child(erase_tab_confirm); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index cd9bb908b87..5bba06f0e28 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -293,7 +293,7 @@ class ScriptEditor : public PanelContainer { void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true); - void _close_current_tab(); + void _close_current_tab(bool p_save = true); void _close_discard_current_tab(const String &p_str); void _close_docs_tab(); void _close_other_tabs();