Merge pull request #90664 from KoBeWi/shadowdropped_resource

Prevent crash when dropping Resource that can't load
This commit is contained in:
Rémi Verschelde 2024-05-30 11:47:38 +02:00
commit aa147b74ea
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 0 deletions

View File

@ -1869,6 +1869,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);