summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-21 13:26:16 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-21 13:26:16 +0200
commit74765691cb4b5989df73d48acf547d120aa46779 (patch)
treeb3b027f22fa71497a8264a3a1e9428ddcd80487b /editor
parent85a46d36b5464182a71f2fe86fb29bff0e203492 (diff)
parentbdff928f6d06661439f4c609cda67a01dd948a39 (diff)
Merge pull request #66191 from MewPurPur/fix-dragndrop-crash-when-scene-closed
Fix possible crash when drag and dropping nodes
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/script_text_editor.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 42dcfb8b1f..1ae4c530e8 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1558,8 +1558,13 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
}
if (d.has("type") && String(d["type"]) == "nodes") {
- Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
+ Node *scene_root = get_tree()->get_edited_scene_root();
+ if (!scene_root) {
+ EditorNode::get_singleton()->show_warning(TTR("Can't drop nodes without an open scene."));
+ return;
+ }
+ Node *sn = _find_script_node(scene_root, scene_root, script);
if (!sn) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Can't drop nodes because script '%s' is not used in this scene."), get_name()));
return;