1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Make more base nodes thread safe

Ongoing work to make more of the base nodes thread safe.
This commit is contained in:
Juan Linietsky
2023-05-12 13:53:15 +02:00
parent fd4a06c515
commit 0a9f72d5a8
17 changed files with 965 additions and 133 deletions

View File

@@ -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);