Skip to content

Commit

Permalink
fix: project settings not properly saved after a file removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunarisnia committed Aug 8, 2024
1 parent 03afb92 commit 138bcc7
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,32 +578,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://", "/");
Expand All @@ -615,6 +617,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.
Expand Down

0 comments on commit 138bcc7

Please sign in to comment.