diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-11-20 16:20:16 -0500 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-20 18:02:42 -0500 |
commit | 9857e4762b8d076259c4be863ba9f53df306d940 (patch) | |
tree | b03c5b5de96e29ffb7e1b008912d21aba5629bc5 /core/io/resource_loader.cpp | |
parent | fd9045fe09e9bea691f0169c16d45cbebddb6bba (diff) | |
parent | 9e6098432aac35bae42c9089a29ba2a80320d823 (diff) | |
download | redot-engine-9857e4762b8d076259c4be863ba9f53df306d940.tar.gz |
Merge commit godotengine/godot@9e6098432aac35bae42c9089a29ba2a80320d823
Diffstat (limited to 'core/io/resource_loader.cpp')
-rw-r--r-- | core/io/resource_loader.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 85781a9591..bd276010bf 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -297,13 +297,13 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin load_paths_stack.push_back(original_path); // Try all loaders and pick the first match for the type hint - bool loader_found = false; + bool found = false; Ref<Resource> res; for (int i = 0; i < loader_count; i++) { if (!loader[i]->recognize_path(p_path, p_type_hint)) { continue; } - loader_found = true; + found = true; res = loader[i]->load(p_path, original_path, r_error, p_use_sub_threads, r_progress, p_cache_mode); if (!res.is_null()) { break; @@ -318,24 +318,15 @@ Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_origin return res; } - if (!loader_found) { - if (r_error) { - *r_error = ERR_FILE_UNRECOGNIZED; - } - ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint)); - } + ERR_FAIL_COND_V_MSG(found, Ref<Resource>(), + vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path)); #ifdef TOOLS_ENABLED Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); - if (!file_check->file_exists(p_path)) { - if (r_error) { - *r_error = ERR_FILE_NOT_FOUND; - } - ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint)); - } + ERR_FAIL_COND_V_MSG(!file_check->file_exists(p_path), Ref<Resource>(), vformat("Resource file not found: %s (expected type: %s)", p_path, p_type_hint)); #endif - ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Failed loading resource: %s. Make sure resources have been imported by opening the project in the editor at least once.", p_path)); + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("No loader found for resource: %s (expected type: %s)", p_path, p_type_hint)); } // This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame. |