summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2024-04-14 15:26:53 +0200
committerkobewi <kobewi4e@gmail.com>2024-04-14 15:26:53 +0200
commit64eff14a460cf51c14d3166f1f87efdd7b5b434d (patch)
treeef30fc15fd433102b1fd6d1de2ae561b97ba20c4 /editor
parentd00734053f9cda8ade5e6c3afd86266e6df571c6 (diff)
downloadredot-engine-64eff14a460cf51c14d3166f1f87efdd7b5b434d.tar.gz
Prevent crash when dropping Resource that can't load
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/script_text_editor.cpp5
1 files changed, 5 insertions, 0 deletions
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> 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);