From 7ed3bfc2fbd19948bc6c2cfa27289e12dbd3410a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20K=C5=99=C3=AD=C5=BE?= Date: Wed, 23 Mar 2022 23:28:51 +0100 Subject: [PATCH] Fix persistent favorites after rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Kříž (cherry picked from commit 0535ef549a6563e374c95ff9bdf6171117a59e6a) --- editor/editor_file_dialog.cpp | 12 ++++++++++++ editor/filesystem_dock.cpp | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 6ce03be34fa..792487386c7 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1199,6 +1199,18 @@ void EditorFileDialog::_update_favorites() { favorite->set_pressed(false); Vector favorited = EditorSettings::get_singleton()->get_favorites(); + + bool fav_changed = false; + for (int i = favorited.size() - 1; i >= 0; i--) { + if (!dir_access->dir_exists(favorited[i])) { + favorited.remove(i); + fav_changed = true; + } + } + if (fav_changed) { + EditorSettings::get_singleton()->set_favorites(favorited); + } + for (int i = 0; i < favorited.size(); i++) { bool cres = favorited[i].begins_with("res://"); if (cres != res) { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 725d7e3715f..5f1bcab7ac6 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -219,6 +219,19 @@ void FileSystemDock::_update_tree(const Vector &p_uncollapsed_paths, boo favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); Vector favorite_paths = EditorSettings::get_singleton()->get_favorites(); + + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + bool fav_changed = false; + for (int i = favorite_paths.size() - 1; i >= 0; i--) { + if (!da->dir_exists(favorite_paths[i])) { + favorite_paths.remove(i); + fav_changed = true; + } + } + if (fav_changed) { + EditorSettings::get_singleton()->set_favorites(favorite_paths); + } + for (int i = 0; i < favorite_paths.size(); i++) { String fave = favorite_paths[i]; if (!fave.begins_with("res://")) {