Merge pull request #46641 from KoBeWi/unsaved_forever

Don't save unchanged script upon closing
This commit is contained in:
Rémi Verschelde 2021-03-06 21:06:06 +01:00 committed by GitHub
commit 05248535f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -755,8 +755,8 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
_save_layout(); _save_layout();
} }
void ScriptEditor::_close_current_tab() { void ScriptEditor::_close_current_tab(bool p_save) {
_close_tab(tab_container->get_current_tab()); _close_tab(tab_container->get_current_tab(), p_save);
} }
void ScriptEditor::_close_discard_current_tab(const String &p_str) { void ScriptEditor::_close_discard_current_tab(const String &p_str) {
@ -802,7 +802,7 @@ void ScriptEditor::_close_other_tabs() {
} }
} }
_close_current_tab(); _close_current_tab(false);
} }
} }
@ -820,7 +820,7 @@ void ScriptEditor::_close_all_tabs() {
} }
} }
_close_current_tab(); _close_current_tab(false);
} }
} }
@ -1372,7 +1372,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (current->is_unsaved()) { if (current->is_unsaved()) {
_ask_close_current_unsaved_tab(current); _ask_close_current_unsaved_tab(current);
} else { } else {
_close_current_tab(); _close_current_tab(false);
} }
} break; } break;
case FILE_COPY_PATH: { case FILE_COPY_PATH: {
@ -3497,7 +3497,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm = memnew(ConfirmationDialog);
erase_tab_confirm->get_ok_button()->set_text(TTR("Save")); erase_tab_confirm->get_ok_button()->set_text(TTR("Save"));
erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard"); erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard");
erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab)); erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab), varray(true));
erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab));
add_child(erase_tab_confirm); add_child(erase_tab_confirm);

View file

@ -325,7 +325,7 @@ class ScriptEditor : public PanelContainer {
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true); 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_discard_current_tab(const String &p_str);
void _close_docs_tab(); void _close_docs_tab();
void _close_other_tabs(); void _close_other_tabs();