Merge pull request #102630 from KoBeWi/what_the_loop
Improve `_is_drop_valid()` code in EditorPropertyArray
This commit is contained in:
commit
1237536364
@ -569,12 +569,10 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
|
|||||||
if (drop_type == "files") {
|
if (drop_type == "files") {
|
||||||
PackedStringArray files = drag_data["files"];
|
PackedStringArray files = drag_data["files"];
|
||||||
|
|
||||||
for (int i = 0; i < files.size(); i++) {
|
for (const String &file : files) {
|
||||||
const String &file = files[i];
|
const String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
|
||||||
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
|
for (String at : allowed_type.split(",")) {
|
||||||
|
at = at.strip_edges();
|
||||||
for (int j = 0; j < allowed_type.get_slice_count(","); j++) {
|
|
||||||
String at = allowed_type.get_slice(",", j).strip_edges();
|
|
||||||
// Fail if one of the files is not of allowed type.
|
// Fail if one of the files is not of allowed type.
|
||||||
if (!ClassDB::is_parent_class(ftype, at)) {
|
if (!ClassDB::is_parent_class(ftype, at)) {
|
||||||
return false;
|
return false;
|
||||||
@ -594,8 +592,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
|
|||||||
if (subtype_hint_string == "NodePath") {
|
if (subtype_hint_string == "NodePath") {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < subtype_hint_string.get_slice_count(","); j++) {
|
for (String ast : subtype_hint_string.split(",")) {
|
||||||
String ast = subtype_hint_string.get_slice(",", j).strip_edges();
|
ast = ast.strip_edges();
|
||||||
allowed_subtype_array.append(ast);
|
allowed_subtype_array.append(ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -644,8 +642,6 @@ bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||||
ERR_FAIL_COND(!_is_drop_valid(p_data));
|
|
||||||
|
|
||||||
Dictionary drag_data = p_data;
|
Dictionary drag_data = p_data;
|
||||||
const String drop_type = drag_data.get("type", "");
|
const String drop_type = drag_data.get("type", "");
|
||||||
Variant array = object->get_array();
|
Variant array = object->get_array();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user