From 301bedd5d4ae303d19dffb07380590e885e6fca6 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 29 Apr 2021 23:27:52 +0300 Subject: [PATCH] Duplicate DynamicFontData resources in the editor preview generation thread to avoid race condition. --- editor/plugins/editor_preview_plugins.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index f24feae7e70..647dd6b6e42 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -838,14 +838,15 @@ Ref EditorFontPreviewPlugin::generate_from_path(const String &p_path, c ril.ptr()->wait(); RES res = ril.ptr()->get_resource(); Ref sampled_font; + sampled_font.instance(); if (res->is_class("DynamicFont")) { - sampled_font = res->duplicate(); - if (sampled_font->get_outline_color() == Color(1, 1, 1, 1)) { - sampled_font->set_outline_color(Color(0, 0, 0, 1)); + Ref font = res; + sampled_font->set_font_data(font->get_font_data()->duplicate()); + for (int i = 0; i < font->get_fallback_count(); i++) { + sampled_font->add_fallback(font->get_fallback(i)->duplicate()); } } else if (res->is_class("DynamicFontData")) { - sampled_font.instance(); - sampled_font->set_font_data(res); + sampled_font->set_font_data(res->duplicate()); } sampled_font->set_size(50);