diff options
author | Daniel Kříž <Daniel.kriz@protonmail.com> | 2022-03-23 23:28:51 +0100 |
---|---|---|
committer | Daniel Kříž <Daniel.kriz@protonmail.com> | 2022-03-25 09:32:10 +0100 |
commit | 0535ef549a6563e374c95ff9bdf6171117a59e6a (patch) | |
tree | 4a7aad4ccc99c3283a50461154c691f47a3c2fc9 /editor | |
parent | 7538ad81ac2f076fda1e66c9f0c2d120601726ba (diff) |
Fix persistent favorites after rename
Signed-off-by: Daniel Kříž <Daniel.kriz@protonmail.com>
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_file_dialog.cpp | 12 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 31f2f24066..444166764b 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1294,6 +1294,18 @@ void EditorFileDialog::_update_favorites() { favorite->set_pressed(false); Vector<String> 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_at(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 038cc2ab2f..e2fb4aa641 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -224,6 +224,19 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); Vector<String> 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_at(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://")) { |