Skip to content

Commit 64eff14

Browse files
committed
Prevent crash when dropping Resource that can't load
1 parent d007340 commit 64eff14

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

editor/plugins/script_text_editor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,11 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
18381838

18391839
if (drop_modifier_pressed && ResourceLoader::exists(path)) {
18401840
Ref<Resource> resource = ResourceLoader::load(path);
1841+
if (resource.is_null()) {
1842+
// Resource exists, but failed to load. We need only path and name, so we can use a dummy Resource instead.
1843+
resource.instantiate();
1844+
resource->set_path_cache(path);
1845+
}
18411846
text_to_drop += _get_dropped_resource_line(resource, is_empty_line);
18421847
} else {
18431848
text_to_drop += _quote_drop_data(path);

0 commit comments

Comments
 (0)