From 14b82c36a25755b18f6d18102167b50fd4ac01e8 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 9 Oct 2022 13:52:04 +0200 Subject: [PATCH] Defer clearing of ResourceUID cache and silence warnings --- core/io/resource_format_binary.cpp | 7 +++++++ editor/editor_file_system.cpp | 2 +- scene/resources/resource_format_text.cpp | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 2a79067e026..4611528db75 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1042,7 +1042,14 @@ void ResourceLoaderBinary::open(Ref p_f, bool p_no_resources, bool p // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. er.path = ResourceUID::get_singleton()->get_id_path(er.uid); } else { +#ifdef TOOLS_ENABLED + // Silence a warning that can happen during the initial filesystem scan due to cache being regenerated. + if (ResourceLoader::get_resource_uid(res_path) != er.uid) { + WARN_PRINT(String(res_path + ": In external resource #" + itos(i) + ", invalid UUID: " + ResourceUID::get_singleton()->id_to_text(er.uid) + " - using text path instead: " + er.path).utf8().get_data()); + } +#else WARN_PRINT(String(res_path + ": In external resource #" + itos(i) + ", invalid UUID: " + ResourceUID::get_singleton()->id_to_text(er.uid) + " - using text path instead: " + er.path).utf8().get_data()); +#endif } } } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 6f34c677dbf..651501f75e4 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -2422,7 +2422,7 @@ EditorFileSystem::EditorFileSystem() { scan_total = 0; update_script_classes_queued.clear(); - ResourceUID::get_singleton()->clear(); //will be updated on scan + MessageQueue::get_singleton()->push_callable(callable_mp(ResourceUID::get_singleton(), &ResourceUID::clear)); // Will be updated on scan. ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path); } diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index c0d65fb445e..85b538b1d96 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -445,7 +445,14 @@ Error ResourceLoaderText::load() { // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path. path = ResourceUID::get_singleton()->get_id_path(uid); } else { +#ifdef TOOLS_ENABLED + // Silence a warning that can happen during the initial filesystem scan due to cache being regenerated. + if (ResourceLoader::get_resource_uid(path) != uid) { + WARN_PRINT(String(res_path + ":" + itos(lines) + " - ext_resource, invalid UUID: " + uidt + " - using text path instead: " + path).utf8().get_data()); + } +#else WARN_PRINT(String(res_path + ":" + itos(lines) + " - ext_resource, invalid UUID: " + uidt + " - using text path instead: " + path).utf8().get_data()); +#endif } }