From 64eff14a460cf51c14d3166f1f87efdd7b5b434d Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 14 Apr 2024 15:26:53 +0200 Subject: Prevent crash when dropping Resource that can't load --- editor/plugins/script_text_editor.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'editor') diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 0a6eacf11d..53ae38c561 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1838,6 +1838,11 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data if (drop_modifier_pressed && ResourceLoader::exists(path)) { Ref resource = ResourceLoader::load(path); + if (resource.is_null()) { + // Resource exists, but failed to load. We need only path and name, so we can use a dummy Resource instead. + resource.instantiate(); + resource->set_path_cache(path); + } text_to_drop += _get_dropped_resource_line(resource, is_empty_line); } else { text_to_drop += _quote_drop_data(path); -- cgit v1.2.3