From 9a3e0a882214be805dc1c534c2dd6adb15288fd1 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 17 Nov 2024 21:51:11 +0100 Subject: [PATCH] Track script property favorites by UID instead of path --- editor/editor_inspector.cpp | 15 +++++++++------ editor/filesystem_dock.cpp | 8 -------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index fa5a059aa0b..cacd4556ef0 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -4278,7 +4278,8 @@ void EditorInspector::_update_current_favorites() { for (PropertyInfo &p : plist) { if (p.usage & PROPERTY_USAGE_CATEGORY) { - path = favorites.has(p.hint_string) ? p.hint_string : String(); + path = ResourceUID::path_to_uid(p.hint_string); + path = favorites.has(path) ? path : String(); } else if (p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE && !path.is_empty()) { props[path].push_back(p.name); } @@ -4288,18 +4289,20 @@ void EditorInspector::_update_current_favorites() { bool invalid_props = false; for (const KeyValue> &KV : props) { path = KV.key; - for (int i = 0; i < favorites[path].size(); i++) { - String prop = favorites[path][i]; + PackedStringArray &favors = favorites[path]; + + for (int i = 0; i < favors.size(); i++) { + String prop = favors[i]; if (KV.value.has(prop)) { current_favorites.append(prop); } else { invalid_props = true; - favorites[path].erase(prop); + favors.erase(prop); i--; } } - if (favorites[path].is_empty()) { + if (favors.is_empty()) { favorites.erase(path); } } @@ -4344,7 +4347,7 @@ void EditorInspector::_set_property_favorited(const String &p_path, bool p_favor if (p.usage & PROPERTY_USAGE_CATEGORY) { path = p.hint_string; } else if (p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE && p.name == p_path) { - class_name = path; + class_name = ResourceUID::path_to_uid(path); break; } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 3921cde71ef..370cd1f7edd 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1661,14 +1661,6 @@ void FileSystemDock::_update_favorites_after_move(const HashMap } } EditorSettings::get_singleton()->set_favorites(new_favorite_files); - - HashMap favorite_properties = EditorSettings::get_singleton()->get_favorite_properties(); - for (const KeyValue &KV : p_files_renames) { - if (favorite_properties.has(KV.key)) { - favorite_properties.replace_key(KV.key, KV.value); - } - } - EditorSettings::get_singleton()->set_favorite_properties(favorite_properties); } void FileSystemDock::_make_scene_confirm() {