From 98326d88bb9b383235c86620f3e8524d6485691f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 13 Mar 2020 11:13:58 +0100 Subject: [PATCH] Fix bad uses of mutex causing deadlocks --- editor/editor_resource_preview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 3c401a6fc715..98bc5444782c 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -109,9 +109,10 @@ void EditorResourcePreview::_thread_func(void *ud) { void EditorResourcePreview::_preview_ready(const String &p_str, const Ref &p_texture, const Ref &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { - MutexLock lock(preview_mutex); String path = p_str; { + MutexLock lock(preview_mutex); + uint32_t hash = 0; uint64_t modified_time = 0; @@ -364,7 +365,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref &p cache[path_id].order = order++; p_receiver->call(p_receiver_func, path_id, cache[path_id].preview, cache[path_id].small_preview, p_userdata); - preview_mutex.unlock(); return; } @@ -391,7 +391,6 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object if (cache.has(p_path)) { cache[p_path].order = order++; p_receiver->call(p_receiver_func, p_path, cache[p_path].preview, cache[p_path].small_preview, p_userdata); - preview_mutex.unlock(); return; } @@ -436,9 +435,10 @@ void EditorResourcePreview::_bind_methods() { void EditorResourcePreview::check_for_invalidation(const String &p_path) { - MutexLock lock(preview_mutex); bool call_invalidated = false; { + MutexLock lock(preview_mutex); + if (cache.has(p_path)) { uint64_t modified_time = FileAccess::get_modified_time(p_path);