From 0efa59bfdcc9e4ddf2f98f4d8a6575a5556b6ca4 Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Wed, 10 Jun 2020 17:41:42 +0800 Subject: [PATCH] Account for file deletion and renaming in Export Presets Ensure that presets are updated with the latest files when starting up or opening the Project Export dialog. Fixes the error where Godot would attempt to export deleted files that were previously selected. (cherry picked from commit 44094b082d56daa2eab5a8f6c6d73f86d8b18d8b) --- editor/editor_export.cpp | 19 ++++++++++++++++++- editor/editor_export.h | 2 ++ editor/project_export.cpp | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 22ebf406808..3dd36fe1bd8 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -96,6 +96,19 @@ Ref EditorExportPreset::get_platform() const { return platform; } +void EditorExportPreset::update_files_to_export() { + Vector to_remove; + for (Set::Element *E = selected_files.front(); E; E = E->next()) { + if (!FileAccess::exists(E->get())) { + to_remove.push_back(E->get()); + } + } + for (int i = 0; i < to_remove.size(); ++i) { + selected_files.erase(to_remove[i]); + } + EditorExport::singleton->save_presets(); +} + Vector EditorExportPreset::get_files_to_export() const { Vector files; @@ -1382,7 +1395,11 @@ void EditorExport::load_config() { Vector files = config->get_value(section, "export_files"); for (int i = 0; i < files.size(); i++) { - preset->add_export_file(files[i]); + if (!FileAccess::exists(files[i])) { + preset->remove_export_file(files[i]); + } else { + preset->add_export_file(files[i]); + } } } diff --git a/editor/editor_export.h b/editor/editor_export.h index 5e61c1e0abf..2f08d744856 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -95,6 +95,8 @@ public: bool has(const StringName &p_property) const { return values.has(p_property); } + void update_files_to_export(); + Vector get_files_to_export() const; void add_export_file(const String &p_path); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 19476cd4ef8..ff0874f7e51 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -161,6 +161,7 @@ void ProjectExportDialog::_update_presets() { String name = preset->get_name(); if (preset->is_runnable()) name += " (" + TTR("Runnable") + ")"; + preset->update_files_to_export(); presets->add_item(name, preset->get_platform()->get_logo()); }