From 54dff9228c9a5d39521730a9d3acae53fea35ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Tue, 16 Sep 2025 22:16:59 +0800 Subject: [PATCH] Fix the project file was not updated when some files were removed --- editor/file_system/dependency_editor.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/editor/file_system/dependency_editor.cpp b/editor/file_system/dependency_editor.cpp index 15becf365d1..71783cb88e3 100644 --- a/editor/file_system/dependency_editor.cpp +++ b/editor/file_system/dependency_editor.cpp @@ -575,6 +575,14 @@ void DependencyRemoveDialog::show(const Vector &p_folders, const Vector< } void DependencyRemoveDialog::ok_pressed() { + HashMap setting_path_map; + for (const StringName &setting : path_project_settings) { + const String path = ResourceUID::ensure_path(GLOBAL_GET(setting)); + setting_path_map[path] = setting; + } + + bool project_settings_modified = false; + for (const KeyValue &E : all_remove_files) { String file = E.key; @@ -583,23 +591,17 @@ void DependencyRemoveDialog::ok_pressed() { emit_signal(SNAME("resource_removed"), res); res->set_path(""); } - } - HashMap setting_path_map; - for (const StringName &setting : path_project_settings) { - const String path = ResourceUID::ensure_path(GLOBAL_GET(setting)); - setting_path_map[path] = setting; - } - - bool project_settings_modified = false; - for (const String &file : files_to_delete) { // If the file we are deleting for e.g. the main scene, default environment, // or audio bus layout, we must clear its definition in Project Settings. const StringName *setting_name = setting_path_map.getptr(file); if (setting_name) { ProjectSettings::get_singleton()->set(*setting_name, ""); + project_settings_modified = true; } + } + for (const String &file : files_to_delete) { const String path = OS::get_singleton()->get_resource_dir() + file.replace_first("res://", "/"); print_verbose("Moving to trash: " + path); Error err = OS::get_singleton()->move_to_trash(path);