Merge pull request #96904 from RandomShaper/fix_previewer_deadlock

ResourceLoader: Fix deadlocks caused by the resource changed feature
This commit is contained in:
Rémi Verschelde 2024-09-16 13:35:21 +02:00
commit 46d9db565b
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 4 additions and 2 deletions

View file

@ -860,7 +860,7 @@ Ref<Resource> ResourceLoader::_load_complete_inner(LoadToken &p_load_token, Erro
} }
} }
core_bind::Semaphore done; core_bind::Semaphore done;
MessageQueue::get_main_singleton()->push_callable(callable_mp(&done, &core_bind::Semaphore::post)); MessageQueue::get_main_singleton()->push_callable(callable_mp(&done, &core_bind::Semaphore::post).bind(1));
done.wait(); done.wait();
} }
} }

View file

@ -533,8 +533,10 @@ void EditorResourcePreview::stop() {
} }
while (!exited.is_set()) { while (!exited.is_set()) {
// Sync pending work.
OS::get_singleton()->delay_usec(10000); OS::get_singleton()->delay_usec(10000);
RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on rendering server RenderingServer::get_singleton()->sync();
MessageQueue::get_singleton()->flush();
} }
thread.wait_to_finish(); thread.wait_to_finish();