summaryrefslogtreecommitdiffstats
path: root/editor/editor_resource_preview.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2023-05-16 00:31:56 +0200
committerGitHub <noreply@github.com>2023-05-16 00:31:56 +0200
commit8cfa19a078ecc7c5690740a8c669d1ecbd04bb0c (patch)
tree5d5e16393bbca27a0d79835c3e09b15ae6cae937 /editor/editor_resource_preview.cpp
parent313f613352960b4d1455f0e179315de5e582b6ea (diff)
parent0a9f72d5a80c8957ef5172f546c9076089862cef (diff)
downloadredot-engine-8cfa19a078ecc7c5690740a8c669d1ecbd04bb0c.tar.gz
Merge pull request #77000 from reduz/make-more-base-nodes-thread-safe
Make more base nodes thread safe
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r--editor/editor_resource_preview.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 45a100a4e5..f5da9da8e7 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);