From 49f323410bfc2c2df15b8f4321c79da7e402ee1e Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 23 Jul 2021 16:29:49 +0200 Subject: [PATCH] Don't set metadata_label font if it doesn't exist (cherry picked from commit 2846dbf239128baced33a9d5ecd18ef04b51a142) --- editor/plugins/texture_editor_plugin.cpp | 12 +++++++----- editor/plugins/texture_editor_plugin.h | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 201d45cdb60..016bc298636 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -49,11 +49,13 @@ void TexturePreview::_notification(int p_what) { break; } - Ref metadata_label_font = get_font("expression", "EditorFonts")->duplicate(); - metadata_label_font->set_size(16 * EDSCALE); - metadata_label_font->set_outline_size(2 * EDSCALE); - metadata_label_font->set_outline_color(Color::named("black")); - metadata_label->add_font_override("font", metadata_label_font); + if (metadata_label) { + Ref metadata_label_font = get_font("expression", "EditorFonts")->duplicate(); + metadata_label_font->set_size(16 * EDSCALE); + metadata_label_font->set_outline_size(2 * EDSCALE); + metadata_label_font->set_outline_color(Color::named("black")); + metadata_label->add_font_override("font", metadata_label_font); + } checkerboard->set_texture(get_icon("Checkerboard", "EditorIcons")); } break; diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 08edddf2d31..8c57901d43c 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -39,10 +39,10 @@ class TexturePreview : public MarginContainer { GDCLASS(TexturePreview, MarginContainer); private: - TextureRect *texture_display; + TextureRect *texture_display = nullptr; - TextureRect *checkerboard; - Label *metadata_label; + TextureRect *checkerboard = nullptr; + Label *metadata_label = nullptr; protected: void _notification(int p_what);