Merge pull request #95281 from Lunarisnia/fix/project-settings

Fix project settings not properly saved after a file deletion
This commit is contained in:
Rémi Verschelde 2024-08-17 00:46:55 +02:00
commit 1e3258cd18
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -572,32 +572,34 @@ void DependencyRemoveDialog::ok_pressed() {
}
}
bool project_settings_modified = false;
for (int i = 0; i < files_to_delete.size(); ++i) {
// 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.
if (files_to_delete[i] == String(GLOBAL_GET("application/config/icon"))) {
ProjectSettings::get_singleton()->set("application/config/icon", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("application/run/main_scene"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("application/run/main_scene"))) {
ProjectSettings::get_singleton()->set("application/run/main_scene", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("application/boot_splash/image"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("application/boot_splash/image"))) {
ProjectSettings::get_singleton()->set("application/boot_splash/image", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("rendering/environment/defaults/default_environment"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("rendering/environment/defaults/default_environment"))) {
ProjectSettings::get_singleton()->set("rendering/environment/defaults/default_environment", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("display/mouse_cursor/custom_image"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("display/mouse_cursor/custom_image"))) {
ProjectSettings::get_singleton()->set("display/mouse_cursor/custom_image", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("gui/theme/custom"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("gui/theme/custom"))) {
ProjectSettings::get_singleton()->set("gui/theme/custom", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("gui/theme/custom_font"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("gui/theme/custom_font"))) {
ProjectSettings::get_singleton()->set("gui/theme/custom_font", "");
}
if (files_to_delete[i] == String(GLOBAL_GET("audio/buses/default_bus_layout"))) {
project_settings_modified = true;
} else if (files_to_delete[i] == String(GLOBAL_GET("audio/buses/default_bus_layout"))) {
ProjectSettings::get_singleton()->set("audio/buses/default_bus_layout", "");
project_settings_modified = true;
}
String path = OS::get_singleton()->get_resource_dir() + files_to_delete[i].replace_first("res://", "/");
@ -609,6 +611,9 @@ void DependencyRemoveDialog::ok_pressed() {
emit_signal(SNAME("file_removed"), files_to_delete[i]);
}
}
if (project_settings_modified) {
ProjectSettings::get_singleton()->save();
}
if (dirs_to_delete.size() == 0) {
// If we only deleted files we should only need to tell the file system about the files we touched.