Selaa lähdekoodia

Add null check on generating thumbnails for PackedScene

Kongfa Waroros 2 kuukautta sitten
vanhempi
commit
d36a3e5c06
1 muutettua tiedostoa jossa 5 lisäystä ja 0 poistoa
  1. 5 0
      editor/plugins/editor_preview_plugins.cpp

+ 5 - 0
editor/plugins/editor_preview_plugins.cpp

@@ -342,6 +342,11 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
 
 	Node *p_scene = pack->instantiate(); // The instantiated preview scene
 
+	if (!p_scene) {
+		print_error(vformat("Failed to generate scene thumbnail for %s : Failed to instantiate scene", p_path));
+		return Ref<Texture2D>();
+	}
+
 	// Prohibit Viewport class as root when generating thumbnails
 	if (Object::cast_to<Viewport>(p_scene)) {
 		p_scene->queue_free();