summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-02-20 19:32:04 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2023-02-20 21:20:05 +0100
commitb862fc8c9b0c2bf7a2f49a472bf7e2b3ce5925df (patch)
treefa312204ee4ce502345338eda913adcede2f1370
parent618bb173baee926f000bf5611c6aef5d597eeb22 (diff)
Fix cases of resource load tasks not being awaitable
-rw-r--r--core/io/resource_loader.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 041758b126..22bf8571bf 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -447,6 +447,17 @@ Ref<Resource> ResourceLoader::load_threaded_get(const String &p_path, Error *r_e
ThreadLoadTask &load_task = thread_load_tasks[local_path];
+ if (!load_task.cond_var && load_task.status == THREAD_LOAD_IN_PROGRESS) {
+ // A condition variable was never created for this task.
+ // That happens when a load has been initiated with subthreads disabled,
+ // but now another load thread needs to interact with this one (either
+ // because of subthreads being used this time, or because it's simply a
+ // threaded load running on a different thread).
+ // Since we want to be notified when the load ends, we must create the
+ // condition variable now.
+ load_task.cond_var = memnew(ConditionVariable);
+ }
+
//cond var still exists, meaning it's still loading, request poll
if (load_task.cond_var) {
{