From 4e6efd1b07f1c6d53d226977ddc729333b74306a Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 15 Jul 2021 23:45:57 -0400 Subject: Use C++ iterators for Lists in many situations --- editor/groups_editor.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'editor/groups_editor.cpp') diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 0a39768b9a..deedbe104c 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -240,8 +240,7 @@ void GroupDialog::_group_renamed() { List nodes; scene_tree->get_nodes_in_group(selected_group, &nodes); bool removed_all = true; - for (List::Element *E = nodes.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : nodes) { if (_can_edit(node, selected_group)) { undo_redo->add_do_method(node, "remove_from_group", selected_group); undo_redo->add_undo_method(node, "remove_from_group", name); @@ -286,11 +285,11 @@ void GroupDialog::_load_groups(Node *p_current) { List gi; p_current->get_groups(&gi); - for (List::Element *E = gi.front(); E; E = E->next()) { - if (!E->get().persistent) { + for (Node::GroupInfo &E : gi) { + if (!E.persistent) { continue; } - _add_group(E->get().name); + _add_group(E.name); } for (int i = 0; i < p_current->get_child_count(); i++) { @@ -311,10 +310,10 @@ void GroupDialog::_delete_group_pressed(Object *p_item, int p_column, int p_id) List nodes; scene_tree->get_nodes_in_group(name, &nodes); bool removed_all = true; - for (List::Element *E = nodes.front(); E; E = E->next()) { - if (_can_edit(E->get(), name)) { - undo_redo->add_do_method(E->get(), "remove_from_group", name); - undo_redo->add_undo_method(E->get(), "add_to_group", name, true); + for (Node *E : nodes) { + if (_can_edit(E, name)) { + undo_redo->add_do_method(E, "remove_from_group", name); + undo_redo->add_undo_method(E, "add_to_group", name, true); } else { removed_all = false; } @@ -628,8 +627,7 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); - for (List::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo gi = E->get(); + for (GroupInfo &gi : groups) { if (!gi.persistent) { continue; } -- cgit v1.2.3