summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-09-08 13:17:34 +0200
committerGitHub <noreply@github.com>2022-09-08 13:17:34 +0200
commit05896cc5790e75f3413533fb633fd7fa5215dc10 (patch)
tree089eebb8fcf2b78d8c9af9c130d4329a73a5467d /editor/editor_node.cpp
parent8b79a19426c7f5eab04caa573866276c76c70871 (diff)
parent14266d8e66b119f09dcb2fb1fa81a83d4dc84345 (diff)
Merge pull request #65504 from KoBeWi/close_before_saving
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 16bcba74e3..1d2540f0fd 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2655,22 +2655,36 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT: {
if (!p_confirmed) {
tab_closing_idx = _next_unsaved_scene(false);
- _scene_tab_changed(tab_closing_idx);
+ if (tab_closing_idx == -1) {
+ tab_closing_idx = -2; // Only external resources are unsaved.
+ } else {
+ _scene_tab_changed(tab_closing_idx);
+ }
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
- Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
- if (scene_root) {
- String scene_filename = scene_root->get_scene_file_path();
+ if (tab_closing_idx == -2) {
if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
save_confirmation->set_ok_button_text(TTR("Save & Reload"));
- save_confirmation->set_text(vformat(TTR("Save changes to '%s' before reloading?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
+ save_confirmation->set_text(TTR("Save modified resources before reloading?"));
} else {
save_confirmation->set_ok_button_text(TTR("Save & Quit"));
- save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
+ save_confirmation->set_text(TTR("Save modified resources before closing?"));
+ }
+ } else {
+ Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
+ if (scene_root) {
+ String scene_filename = scene_root->get_scene_file_path();
+ if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
+ save_confirmation->set_ok_button_text(TTR("Save & Reload"));
+ save_confirmation->set_text(vformat(TTR("Save changes to '%s' before reloading?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
+ } else {
+ save_confirmation->set_ok_button_text(TTR("Save & Quit"));
+ save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
+ }
}
- save_confirmation->popup_centered();
- break;
}
+ save_confirmation->popup_centered();
+ break;
}
}
if (!editor_data.get_edited_scene_root(tab_closing_idx)) {
@@ -2943,7 +2957,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
case RELOAD_CURRENT_PROJECT: {
if (!p_confirmed) {
bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit");
- if (_next_unsaved_scene(!save_each) == -1) {
+ if (_next_unsaved_scene(!save_each) == -1 && !get_undo_redo()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY)) {
_discard_changes();
break;
} else {