From cd8eaaa07bad670bed17bee248b75245999a56ed Mon Sep 17 00:00:00 2001 From: Thomas ten Cate Date: Sat, 8 Feb 2025 11:29:51 +0100 Subject: [PATCH] Fix resource property editor incorrectly accepting script files See discussion on #102534. Before this fix, it was possible to drag a file `CustomResource.gd` with `class_name CustomResource` onto a property of type `CustomResource`. Of course, the intention is that only `Resource`s with the `CustomResource` script attached are accepted. (Actually accepting the script, but creating a resource from it automatically, is left as a future improvement.) --- editor/editor_resource_picker.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 96fb832370..1f3700c480 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -686,9 +686,11 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const { return true; } - StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res.ptr()); - if (_is_type_valid(custom_class, allowed_types)) { - return true; + if (res->get_script()) { + StringName custom_class = EditorNode::get_singleton()->get_object_custom_type_name(res->get_script()); + if (_is_type_valid(custom_class, allowed_types)) { + return true; + } } }