Skip to content

Commit

Permalink
ResourceLoader: Fixup management of thread-specific status
Browse files Browse the repository at this point in the history
- Allows the message queue override to flush after loading each resource, which was the original intent.
- Removes a redundant call to mark the thread as safe-for-nodes.
  • Loading branch information
RandomShaper committed Jul 8, 2024
1 parent 42e5b3a commit f952d39
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
thread_load_mutex.unlock();

// Thread-safe either if it's the current thread or a brand new one.
bool mq_override_present = false;
thread_local bool mq_override_present = false;
CallQueue *own_mq_override = nullptr;
if (load_nesting == 0) {
mq_override_present = false;
load_paths_stack = memnew(Vector<String>);

if (!load_task.dependent_path.is_empty()) {
Expand All @@ -326,10 +327,6 @@ void ResourceLoader::_thread_load_function(void *p_userdata) {
}
// --

if (!Thread::is_main_thread()) {
set_current_thread_safe_for_nodes(true);
}

Ref<Resource> res = _load(load_task.remapped_path, load_task.remapped_path != load_task.local_path ? load_task.local_path : String(), load_task.type_hint, load_task.cache_mode, &load_task.error, load_task.use_sub_threads, &load_task.progress);
if (mq_override_present) {
MessageQueue::get_singleton()->flush();
Expand Down

0 comments on commit f952d39

Please sign in to comment.