diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-13 13:52:41 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-13 13:52:41 +0200 |
commit | 4177f262fb67cd7d7cd03c8fb2f48352d0f8600b (patch) | |
tree | 9942b1b3890f4fa0889f403333f92f0b52d8e947 | |
parent | 5288a69a2235a1b31e006aa65160e4051e5ea51d (diff) | |
parent | 06eff95d64a9b387a442d31fc8d133ae942ad8aa (diff) | |
download | redot-engine-4177f262fb67cd7d7cd03c8fb2f48352d0f8600b.tar.gz |
Merge pull request #73131 from KoBeWi/decency_editor
Fix missing UID handling in Dependency Editor
-rw-r--r-- | editor/dependency_editor.cpp | 14 | ||||
-rw-r--r-- | scene/resources/resource_format_text.cpp | 12 |
2 files changed, 20 insertions, 6 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index eaafad7ab8..3660e7f285 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -191,10 +191,16 @@ void DependencyEditor::_update_list() { ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(path); if (uid != ResourceUID::INVALID_ID) { - // dependency is in uid format, obtain proper path - ERR_CONTINUE(!ResourceUID::get_singleton()->has_id(uid)); - - path = ResourceUID::get_singleton()->get_id_path(uid); + // Dependency is in uid format, obtain proper path. + if (ResourceUID::get_singleton()->has_id(uid)) { + path = ResourceUID::get_singleton()->get_id_path(uid); + } else if (n.get_slice_count("::") >= 3) { + // If uid can't be found, try to use fallback path. + path = n.get_slice("::", 2); + } else { + ERR_PRINT("Invalid dependency UID and fallback path."); + continue; + } } String name = path.get_file(); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index c3628125b4..7719cc28d2 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -851,26 +851,34 @@ void ResourceLoaderText::get_dependencies(Ref<FileAccess> p_f, List<String> *p_d String path = next_tag.fields["path"]; String type = next_tag.fields["type"]; + String fallback_path; bool using_uid = false; if (next_tag.fields.has("uid")) { - //if uid exists, return uid in text format, not the path + // If uid exists, return uid in text format, not the path. String uidt = next_tag.fields["uid"]; ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(uidt); if (uid != ResourceUID::INVALID_ID) { + fallback_path = path; // Used by Dependency Editor, in case uid path fails. path = ResourceUID::get_singleton()->id_to_text(uid); using_uid = true; } } if (!using_uid && !path.contains("://") && path.is_relative_path()) { - // path is relative to file being loaded, so convert to a resource path + // Path is relative to file being loaded, so convert to a resource path. path = ProjectSettings::get_singleton()->localize_path(local_path.get_base_dir().path_join(path)); } if (p_add_types) { path += "::" + type; } + if (!fallback_path.is_empty()) { + if (!p_add_types) { + path += "::"; // Ensure that path comes third, even if there is no type. + } + path += "::" + fallback_path; + } p_dependencies->push_back(path); |