summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Gilleron <marc.gilleron@gmail.com>2021-12-18 03:35:29 +0000
committerMarc Gilleron <marc.gilleron@gmail.com>2021-12-18 03:35:29 +0000
commitccb701f2f79473b8d2881888bd22d7e9f2c2587e (patch)
treedd11bbf8061a74b97b11e5743ab38c35d7e31b3f
parent58712e96aea12bda2d5111d96961f529d15a693c (diff)
Fix crash if font fails loading when generating a preview
Historical crash log: ERROR: No loader found for resource: res://addons/gdquest.mannequin/assets/theme/fonts/montserrat/Montserrat-Medium.ttf. at: (core\io\resource_loader.cpp:213) ERROR: res://addons/gdquest.mannequin/assets/theme/fonts/default_font.tres:8 - Parse Error: [ext_resource] referenced non-loaded resource at: res://addons/gdquest.mannequin/assets/theme/fonts/montserrat/Montserrat-Medium.ttf at: ResourceLoaderText::_parse_ext_resource (scene\resources\resource_format_text.cpp:170) ERROR: res://addons/gdquest.mannequin/assets/theme/fonts/default_font.tres:8 - Parse Error: [ext_resource] referenced non-loaded resource at: res://addons/gdquest.mannequin/assets/theme/fonts/montserrat/Montserrat-Medium.ttf at: ResourceLoaderText::load (scene\resources\resource_format_text.cpp:649) ERROR: Failed loading resource: res://addons/gdquest.mannequin/assets/theme/fonts/default_font.tres. Make sure resources have been imported by opening the project in the editor at least once. at: (core\io\resource_loader.cpp:206)
-rw-r--r--editor/plugins/editor_preview_plugins.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 3b85fad345..871b72d9c3 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -824,6 +824,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const {
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
RES res = ResourceLoader::load(p_path);
+ ERR_FAIL_COND_V(res.is_null(), Ref<Texture2D>());
Ref<Font> sampled_font;
if (res->is_class("Font")) {
sampled_font = res->duplicate();