diff options
author | kobewi <kobewi4e@gmail.com> | 2024-04-14 15:26:53 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-04-14 15:26:53 +0200 |
commit | 64eff14a460cf51c14d3166f1f87efdd7b5b434d (patch) | |
tree | ef30fc15fd433102b1fd6d1de2ae561b97ba20c4 /editor | |
parent | d00734053f9cda8ade5e6c3afd86266e6df571c6 (diff) | |
download | redot-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.cpp | 5 |
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); |