Skip to content

Commit 420d761

Browse files
committed
Merge pull request godotengine#106714 from jorgekorgut/fix-ignore-external-changes
Fix Ignore External Changes Bug
2 parents f3f76df + f165ee2 commit 420d761

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

editor/editor_node.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,21 +1304,27 @@ void EditorNode::_scan_external_changes() {
13041304
disk_changed_list->set_hide_root(true);
13051305
bool need_reload = false;
13061306

1307-
// Check if any edited scene has changed.
1307+
disk_changed_scenes.clear();
1308+
disk_changed_project = false;
13081309

1310+
// Check if any edited scene has changed.
13091311
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
13101312
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
1311-
if (editor_data.get_scene_path(i) == "" || !da->file_exists(editor_data.get_scene_path(i))) {
1313+
1314+
const String scene_path = editor_data.get_scene_path(i);
1315+
1316+
if (scene_path == "" || !da->file_exists(scene_path)) {
13121317
continue;
13131318
}
13141319

13151320
uint64_t last_date = editor_data.get_scene_modified_time(i);
1316-
uint64_t date = FileAccess::get_modified_time(editor_data.get_scene_path(i));
1321+
uint64_t date = FileAccess::get_modified_time(scene_path);
13171322

13181323
if (date > last_date) {
13191324
TreeItem *ti = disk_changed_list->create_item(r);
1320-
ti->set_text(0, editor_data.get_scene_path(i).get_file());
1325+
ti->set_text(0, scene_path.get_file());
13211326
need_reload = true;
1327+
disk_changed_scenes.push_back(scene_path);
13221328
}
13231329
}
13241330

@@ -1327,16 +1333,23 @@ void EditorNode::_scan_external_changes() {
13271333
TreeItem *ti = disk_changed_list->create_item(r);
13281334
ti->set_text(0, "project.godot");
13291335
need_reload = true;
1336+
disk_changed_project = true;
13301337
}
13311338

13321339
if (need_reload) {
13331340
callable_mp((Window *)disk_changed, &Window::popup_centered_ratio).call_deferred(0.3);
13341341
}
13351342
}
13361343

1337-
void EditorNode::_resave_scenes(String p_str) {
1338-
save_all_scenes();
1339-
ProjectSettings::get_singleton()->save();
1344+
void EditorNode::_resave_externally_modified_scenes(String p_str) {
1345+
for (const String &scene_path : disk_changed_scenes) {
1346+
_save_scene(scene_path);
1347+
}
1348+
1349+
if (disk_changed_project) {
1350+
ProjectSettings::get_singleton()->save();
1351+
}
1352+
13401353
disk_changed->hide();
13411354
}
13421355

@@ -8304,7 +8317,7 @@ EditorNode::EditorNode() {
83048317
disk_changed->set_ok_button_text(TTR("Reload from disk"));
83058318

83068319
disk_changed->add_button(TTR("Ignore external changes"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
8307-
disk_changed->connect("custom_action", callable_mp(this, &EditorNode::_resave_scenes));
8320+
disk_changed->connect("custom_action", callable_mp(this, &EditorNode::_resave_externally_modified_scenes));
83088321
}
83098322

83108323
gui_base->add_child(disk_changed);

editor/editor_node.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ class EditorNode : public Node {
435435
EditorBottomPanel *bottom_panel = nullptr;
436436

437437
Tree *disk_changed_list = nullptr;
438+
LocalVector<String> disk_changed_scenes;
439+
bool disk_changed_project = false;
438440
ConfirmationDialog *disk_changed = nullptr;
439441
ConfirmationDialog *project_data_missing = nullptr;
440442

@@ -675,7 +677,7 @@ class EditorNode : public Node {
675677
void _scan_external_changes();
676678
void _reload_modified_scenes();
677679
void _reload_project_settings();
678-
void _resave_scenes(String p_str);
680+
void _resave_externally_modified_scenes(String p_str);
679681

680682
void _feature_profile_changed();
681683
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);

0 commit comments

Comments
 (0)