From ccb701f2f79473b8d2881888bd22d7e9f2c2587e Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Sat, 18 Dec 2021 03:35:29 +0000 Subject: [PATCH] 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) --- editor/plugins/editor_preview_plugins.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 3b85fad345f..871b72d9c3a 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 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()); Ref sampled_font; if (res->is_class("Font")) { sampled_font = res->duplicate();