Skip to content

Commit b9a6057

Browse files
committed
Improve _is_drop_valid() code in EditorPropertyArray
1 parent 36d90c7 commit b9a6057

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

editor/editor_properties_array_dict.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,10 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
570570
if (drop_type == "files") {
571571
PackedStringArray files = drag_data["files"];
572572

573-
for (int i = 0; i < files.size(); i++) {
574-
const String &file = files[i];
575-
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
576-
577-
for (int j = 0; j < allowed_type.get_slice_count(","); j++) {
578-
String at = allowed_type.get_slice(",", j).strip_edges();
573+
for (const String &file : files) {
574+
const String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
575+
for (String at : allowed_type.split(",")) {
576+
at = at.strip_edges();
579577
// Fail if one of the files is not of allowed type.
580578
if (!ClassDB::is_parent_class(ftype, at)) {
581579
return false;
@@ -595,8 +593,8 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
595593
if (subtype_hint_string == "NodePath") {
596594
return true;
597595
} else {
598-
for (int j = 0; j < subtype_hint_string.get_slice_count(","); j++) {
599-
String ast = subtype_hint_string.get_slice(",", j).strip_edges();
596+
for (String ast : subtype_hint_string.split(",")) {
597+
ast = ast.strip_edges();
600598
allowed_subtype_array.append(ast);
601599
}
602600
}
@@ -645,8 +643,6 @@ bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant
645643
}
646644

647645
void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
648-
ERR_FAIL_COND(!_is_drop_valid(p_data));
649-
650646
Dictionary drag_data = p_data;
651647
const String drop_type = drag_data.get("type", "");
652648
Variant array = object->get_array();

0 commit comments

Comments
 (0)