diff options
| author | robfram | 2018-03-17 18:52:39 +0100 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-04-28 17:22:29 +0200 |
| commit | 7563c17113790fe66a816c781001791bd571ef3c (patch) | |
| tree | 3da83263b28522dd28acf403dd4d2713ca468cdd /editor/editor_node.cpp | |
| parent | 43dcf239901acfb6e2e27126b611c7b0da919798 (diff) | |
| download | godot-7563c17113790fe66a816c781001791bd571ef3c.tar.gz godot-7563c17113790fe66a816c781001791bd571ef3c.tar.zst godot-7563c17113790fe66a816c781001791bd571ef3c.zip | |
Fix saving unmodified scenes and resources
When `_save_all_scenes` or `save_resource_in_path` was called, they
always saved all the scenes and the resource no matter if they were
modified or not. For example, when `saving before run` option was
checked, it always overwrote the current scene and the default
environment simply by opening and runing the project.
This PR adds checks for unsaved scenes (using the same `unsave` check
others method used) and modified resources (comparing last modified
time and last import time).
Fix #6025.
(cherry picked from commit 28ab60422d648d43d219186ea0ecffce1645188f)
Diffstat (limited to 'editor/editor_node.cpp')
| -rw-r--r-- | editor/editor_node.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1b974edb2..0bff56bec 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -587,6 +587,10 @@ void EditorNode::open_resource(const String &p_type) { void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) { editor_data.apply_changes_in_editors(); + if (p_resource->get_last_modified_time() == p_resource->get_import_last_modified_time()) { + return; + } + int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; @@ -1072,7 +1076,8 @@ void EditorNode::_save_scene(String p_file, int idx) { void EditorNode::_save_all_scenes() { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + int i = _next_unsaved_scene(true, 0); + while (i != -1) { Node *scene = editor_data.get_edited_scene_root(i); if (scene && scene->get_filename() != "") { if (i != editor_data.get_edited_scene()) @@ -1080,6 +1085,7 @@ void EditorNode::_save_all_scenes() { else _save_scene_with_preview(scene->get_filename()); } // else: ignore new scenes + i = _next_unsaved_scene(true, ++i); } _save_default_environment(); |
