diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d606db620c19..cb7ca60d41cf 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -325,7 +325,12 @@ void ResourceLoader::_thread_load_function(void *p_userdata) { MessageQueue::get_singleton()->flush(); } + // We just need to sync with the latest writes. No critical section needed. + // As a good side effect, the mutex is unlocked, which is a requirement if + // some of the calls below to set the resource up invoke code that in turns + // requests resource loading. thread_load_mutex.lock(); + thread_load_mutex.unlock(); load_task.resource = res; @@ -389,8 +394,6 @@ void ResourceLoader::_thread_load_function(void *p_userdata) { } } - thread_load_mutex.unlock(); - if (load_nesting == 0) { if (own_mq_override) { MessageQueue::set_thread_singleton_override(nullptr);