Browse Source

Don't set metadata_label font if it doesn't exist

(cherry picked from commit 2846dbf239128baced33a9d5ecd18ef04b51a142)
kobewi 4 years ago
parent
commit
49f323410b
2 changed files with 10 additions and 8 deletions
  1. 7 5
      editor/plugins/texture_editor_plugin.cpp
  2. 3 3
      editor/plugins/texture_editor_plugin.h

+ 7 - 5
editor/plugins/texture_editor_plugin.cpp

@@ -49,11 +49,13 @@ void TexturePreview::_notification(int p_what) {
 				break;
 			}
 
-			Ref<DynamicFont> 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<DynamicFont> 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;

+ 3 - 3
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);