From 7c02f5cd5c720f7dde4b93765e0443b1e4005eb9 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 31 Jan 2024 06:38:25 -0600 Subject: [PATCH] [4.2] Fix crash when previewing a scene with a mesh as the root node (cherry picked from commit 424a6a6bf5109a099a51e42f5e1737aab70f66da) --- editor/import/scene_import_settings.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 8122f588716..f9f35445d02 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -310,7 +310,10 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { Ref 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;