1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Merge pull request #111387 from Chaosed0/core/fix-resource-loader-ignore-cache

Fix `load_threaded_get` returning `null` when used with `CACHE_MODE_IGNORE`
This commit is contained in:
Thaddeus Crews
2025-12-10 18:10:27 -06:00

View File

@@ -706,10 +706,17 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const
}
String local_path = _validate_local_path(p_path);
ERR_FAIL_COND_V_MSG(!thread_load_tasks.has(local_path), THREAD_LOAD_INVALID_RESOURCE, "Bug in ResourceLoader logic, please report.");
LoadToken *load_token = user_load_tokens[p_path];
ThreadLoadTask *load_task_ptr;
ThreadLoadTask &load_task = thread_load_tasks[local_path];
status = load_task.status;
if (load_token->task_if_unregistered) {
load_task_ptr = load_token->task_if_unregistered;
} else {
ERR_FAIL_COND_V_MSG(!thread_load_tasks.has(local_path), THREAD_LOAD_INVALID_RESOURCE, "Bug in ResourceLoader logic, please report.");
load_task_ptr = &thread_load_tasks[local_path];
}
status = load_task_ptr->status;
if (r_progress) {
*r_progress = _dependency_get_progress(local_path);
}
@@ -717,10 +724,10 @@ ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const
// Support userland polling in a loop on the main thread.
if (Thread::is_main_thread() && status == THREAD_LOAD_IN_PROGRESS) {
uint64_t frame = Engine::get_singleton()->get_process_frames();
if (frame == load_task.last_progress_check_main_thread_frame) {
if (frame == load_task_ptr->last_progress_check_main_thread_frame) {
ensure_progress = true;
} else {
load_task.last_progress_check_main_thread_frame = frame;
load_task_ptr->last_progress_check_main_thread_frame = frame;
}
}
}
@@ -754,8 +761,23 @@ Ref<Resource> ResourceLoader::load_threaded_get(const String &p_path, Error *r_e
// Support userland requesting on the main thread before the load is reported to be complete.
if (Thread::is_main_thread() && !load_token->local_path.is_empty()) {
const ThreadLoadTask &load_task = thread_load_tasks[load_token->local_path];
while (load_task.status == THREAD_LOAD_IN_PROGRESS) {
ThreadLoadTask *load_task_ptr;
if (load_token->task_if_unregistered) {
load_task_ptr = load_token->task_if_unregistered;
} else {
if (!thread_load_tasks.has(load_token->local_path)) {
print_error("Bug in ResourceLoader logic, please report.");
if (r_error) {
*r_error = ERR_BUG;
}
return Ref<Resource>();
}
load_task_ptr = &thread_load_tasks[load_token->local_path];
}
while (load_task_ptr->status == THREAD_LOAD_IN_PROGRESS) {
thread_load_lock.temp_unlock();
bool exit = !_ensure_load_progress();
OS::get_singleton()->delay_usec(1000);