diff options
author | Juan Linietsky <reduzio@gmail.com> | 2023-05-12 13:53:15 +0200 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2023-05-15 16:54:10 +0200 |
commit | 0a9f72d5a80c8957ef5172f546c9076089862cef (patch) | |
tree | 250a57d39630efd1a290efd897d11a838dd53867 /editor/editor_resource_preview.cpp | |
parent | fd4a06c51555904104b18494d0224f450d74fe2a (diff) | |
download | redot-engine-0a9f72d5a80c8957ef5172f546c9076089862cef.tar.gz |
Make more base nodes thread safe
Ongoing work to make more of the base nodes thread safe.
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r-- | editor/editor_resource_preview.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 7dea1a7e01..1db3700528 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -158,8 +158,6 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } r_texture = generated; - int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))->get_width(); // Kind of a workaround to retrieve the default icon size - if (preview_generators[i]->can_generate_small_preview()) { Ref<Texture2D> generated_small; Dictionary d; @@ -340,9 +338,16 @@ void EditorResourcePreview::_thread() { exited.set(); } +void EditorResourcePreview::_update_thumbnail_sizes() { + if (small_thumbnail_size == -1) { + small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))->get_width(); // Kind of a workaround to retrieve the default icon size + } +} + void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) { ERR_FAIL_NULL(p_receiver); ERR_FAIL_COND(!p_res.is_valid()); + _update_thumbnail_sizes(); { MutexLock lock(preview_mutex); @@ -370,6 +375,8 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p } void EditorResourcePreview::queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) { + _update_thumbnail_sizes(); + ERR_FAIL_NULL(p_receiver); { MutexLock lock(preview_mutex); |