summaryrefslogtreecommitdiff
path: root/editor/editor_resource_preview.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-03-13 13:18:48 +0100
committerGitHub <noreply@github.com>2020-03-13 13:18:48 +0100
commit88dd5d374fd4f9653b37b93a08df6ddac035f0ea (patch)
tree8ef2cf4b9505fbaf86c0b06db77aa157e07d993c /editor/editor_resource_preview.cpp
parent5002f6de84cd188a92b9e10debbf196b399973ac (diff)
parent98326d88bb9b383235c86620f3e8524d6485691f (diff)
Merge pull request #37023 from RandomShaper/fix_resource_preview_mutex
Fix bad uses of mutex causing deadlocks
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r--editor/editor_resource_preview.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 3c401a6fc7..98bc544478 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<Texture2D> &p_texture, const Ref<Texture2D> &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<Resource> &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);