Skip to content

Commit

Permalink
Merge pull request #876 from Spartan322/revert/a0c1744
Browse files Browse the repository at this point in the history
[4.3] Revert "ResourceLoader: Report error if resource type unrecognized"
  • Loading branch information
Spartan322 authored Nov 21, 2024
2 parents 9ba2401 + e6c4359 commit a06b0a0
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,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;
Expand All @@ -307,24 +307,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.
Expand Down

0 comments on commit a06b0a0

Please sign in to comment.