Ver Fonte

Merge pull request #96904 from RandomShaper/fix_previewer_deadlock

ResourceLoader: Fix deadlocks caused by the resource changed feature
Rémi Verschelde há 1 ano atrás
pai
commit
46d9db565b
2 ficheiros alterados com 4 adições e 2 exclusões
  1. 1 1
      core/io/resource_loader.cpp
  2. 3 1
      editor/editor_resource_preview.cpp

+ 1 - 1
core/io/resource_loader.cpp

@@ -860,7 +860,7 @@ Ref<Resource> ResourceLoader::_load_complete_inner(LoadToken &p_load_token, Erro
 						}
 					}
 					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();
 				}
 			}

+ 3 - 1
editor/editor_resource_preview.cpp

@@ -533,8 +533,10 @@ void EditorResourcePreview::stop() {
 			}
 
 			while (!exited.is_set()) {
+				// Sync pending work.
 				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();