From 4ff5326959fa2a369ccb9663a2e5838db62f1215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Fri, 12 Apr 2024 13:08:53 +0800 Subject: [PATCH] Fix crash when dragging scene files to 2D/3D screen The crash usually occurs when there is no scene root node. --- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- editor/plugins/node_3d_editor_plugin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 41e5eee486e5..8d24e90ccef2 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5944,7 +5944,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian } Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); - if (_cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) { + if (edited_scene && !edited_scene->get_scene_file_path().is_empty() && _cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) { memdelete(instantiated_scene); can_instantiate = false; is_cyclical_dep = true; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 88250ea3c37a..aea3ea970058 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4507,7 +4507,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant continue; } Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); - if (_cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) { + if (edited_scene && !edited_scene->get_scene_file_path().is_empty() && _cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) { memdelete(instantiated_scene); can_instantiate = false; is_cyclical_dep = true;