Browse Source

[4.2] Fix crash when previewing a scene with a mesh as the root node

(cherry picked from commit 424a6a6bf5109a099a51e42f5e1737aab70f66da)
Aaron Franke 1 year ago
parent
commit
7c02f5cd5c
1 changed files with 4 additions and 1 deletions
  1. 4 1
      editor/import/scene_import_settings.cpp

+ 4 - 1
editor/import/scene_import_settings.cpp

@@ -310,7 +310,10 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) {
 			Ref<ImporterMesh> editor_mesh = src_mesh_node->get_mesh();
 			mesh_node->set_mesh(editor_mesh->get_mesh());
 		}
-
+		// Replace the original mesh node in the scene tree with the new one.
+		if (unlikely(p_node == scene)) {
+			scene = mesh_node;
+		}
 		p_node->replace_by(mesh_node);
 		memdelete(p_node);
 		p_node = mesh_node;