Skip to content

Fix Ignore External Changes Bug #106714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,21 +1304,27 @@ void EditorNode::_scan_external_changes() {
disk_changed_list->set_hide_root(true);
bool need_reload = false;

// Check if any edited scene has changed.
disk_changed_scenes.clear();
disk_changed_project = false;

// Check if any edited scene has changed.
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (editor_data.get_scene_path(i) == "" || !da->file_exists(editor_data.get_scene_path(i))) {

const String scene_path = editor_data.get_scene_path(i);

if (scene_path == "" || !da->file_exists(scene_path)) {
continue;
}

uint64_t last_date = editor_data.get_scene_modified_time(i);
uint64_t date = FileAccess::get_modified_time(editor_data.get_scene_path(i));
uint64_t date = FileAccess::get_modified_time(scene_path);

if (date > last_date) {
TreeItem *ti = disk_changed_list->create_item(r);
ti->set_text(0, editor_data.get_scene_path(i).get_file());
ti->set_text(0, scene_path.get_file());
need_reload = true;
disk_changed_scenes.push_back(scene_path);
}
}

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

if (need_reload) {
callable_mp((Window *)disk_changed, &Window::popup_centered_ratio).call_deferred(0.3);
}
}

void EditorNode::_resave_scenes(String p_str) {
save_all_scenes();
ProjectSettings::get_singleton()->save();
void EditorNode::_resave_externally_modified_scenes(String p_str) {
for (const String &scene_path : disk_changed_scenes) {
_save_scene(scene_path);
}

if (disk_changed_project) {
ProjectSettings::get_singleton()->save();
}

disk_changed->hide();
}

Expand Down Expand Up @@ -8293,7 +8306,7 @@ EditorNode::EditorNode() {
disk_changed->set_ok_button_text(TTR("Reload from disk"));

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

gui_base->add_child(disk_changed);
Expand Down
4 changes: 3 additions & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ class EditorNode : public Node {
EditorBottomPanel *bottom_panel = nullptr;

Tree *disk_changed_list = nullptr;
LocalVector<String> disk_changed_scenes;
bool disk_changed_project = false;
ConfirmationDialog *disk_changed = nullptr;
ConfirmationDialog *project_data_missing = nullptr;

Expand Down Expand Up @@ -674,7 +676,7 @@ class EditorNode : public Node {
void _scan_external_changes();
void _reload_modified_scenes();
void _reload_project_settings();
void _resave_scenes(String p_str);
void _resave_externally_modified_scenes(String p_str);

void _feature_profile_changed();
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
Expand Down