summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2024-08-13 13:32:12 +0200
committerGitHub <noreply@github.com>2024-08-13 13:32:12 +0200
commit28e65b0e4e84d503d3cbdb947c83cba9f02b8f1c (patch)
tree326edf1d334fe80f9701b155387fa0a7a8ec8672
parenta7a124a57d643103c882a781dfe1f3772363ecc7 (diff)
parent17ea4b405a554e1eb50d852316f71cf26425047c (diff)
downloadredot-engine-28e65b0e4e84d503d3cbdb947c83cba9f02b8f1c.tar.gz
Merge pull request #95476 from RandomShaper/uncached_progress
ResourceLoader: Fix error on querying progress for uncached loads
-rw-r--r--core/io/resource_loader.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index c5582ad231..928bb95de3 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -474,6 +474,7 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
bool ignoring_cache = p_cache_mode == ResourceFormatLoader::CACHE_MODE_IGNORE || p_cache_mode == ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP;
Ref<LoadToken> load_token;
+ bool must_not_register = false;
ThreadLoadTask unregistered_load_task; // Once set, must be valid up to the call to do the load.
ThreadLoadTask *load_task_ptr = nullptr;
bool run_on_current_thread = false;
@@ -516,8 +517,9 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
}
}
- // Cache-ignoring tasks aren't registered in the map and so must finish within scope.
- if (ignoring_cache) {
+ // If we want to ignore cache, but there's another task loading it, we can't add this one to the map and we also have to finish within scope.
+ must_not_register = ignoring_cache && thread_load_tasks.has(local_path);
+ if (must_not_register) {
load_token->local_path.clear();
unregistered_load_task = load_task;
load_task_ptr = &unregistered_load_task;
@@ -528,7 +530,7 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
}
}
- run_on_current_thread = ignoring_cache || p_thread_mode == LOAD_THREAD_FROM_CURRENT;
+ run_on_current_thread = must_not_register || p_thread_mode == LOAD_THREAD_FROM_CURRENT;
if (run_on_current_thread) {
load_task_ptr->thread_id = Thread::get_caller_id();
@@ -539,7 +541,7 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
if (run_on_current_thread) {
_thread_load_function(load_task_ptr);
- if (ignoring_cache) {
+ if (must_not_register) {
load_token->res_if_unregistered = load_task_ptr->resource;
}
}