Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix errors when dragging non-file data onto path properties

014-codec74f668045eb
diff --git a/editor/inspector/editor_properties.cpp b/editor/inspector/editor_properties.cpp
index c3b2f258866..b7f73c2b69b 100644
--- a/editor/inspector/editor_properties.cpp
+++ b/editor/inspector/editor_properties.cpp
@@ -814,14 +814,18 @@ void EditorPropertyPath::_drop_data_fw(const Point2 &p_point, const Variant &p_d
bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
const Dictionary drag_data = p_data;
- if (!drag_data.has("type")) {
- return false;
- }
- const Vector<String> filesPaths = drag_data["files"];
+ const String type = drag_data.get("type", "");
if (folder) {
- if (String(drag_data["type"]) != "files_and_dirs") {
+ if (type != "files_and_dirs") {
+ return false;
+ }
+ } else {
+ if (type != "files") {
return false;
}
+ }
+ const Vector<String> filesPaths = drag_data["files"];
+ if (folder) {
if (filesPaths.size() > 1) {
for (const String &p : filesPaths) {
if (!p.ends_with("/")) {
@@ -831,9 +835,6 @@ bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant
}
return true;
} else {
- if (String(drag_data["type"]) != "files") {
- return false;
- }
if (filesPaths.is_empty()) {
return false;
}