Using iterator pattern instead of List::Element *.

Co-authored-by: Adam Scott <ascott.ca@gmail.com>
This commit is contained in:
Yyf2333 2025-02-03 14:16:27 +08:00 committed by Yufeng Ying
parent 594d64ec24
commit 22b5ec17fb
36 changed files with 150 additions and 173 deletions

View file

@ -643,14 +643,14 @@ void AnimationNodeStateMachineEditor::_open_menu(const Vector2 &p_position) {
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
classes.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
String name = String(E->get()).replace_first("AnimationNode", "");
for (const StringName &class_name : classes) {
String name = String(class_name).replace_first("AnimationNode", "");
if (name == "Animation" || name == "StartState" || name == "EndState") {
continue; // nope
}
int idx = menu->get_item_count();
menu->add_item(vformat(TTR("Add %s"), name), idx);
menu->set_item_metadata(idx, E->get());
menu->set_item_metadata(idx, class_name);
}
Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard();
@ -2019,16 +2019,16 @@ void EditorAnimationMultiTransitionEdit::_get_property_list(List<PropertyInfo> *
prop_transition_path.name = itos(i) + "/" + "transition_path";
p_list->push_back(prop_transition_path);
for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) {
if (F->get().name == "script" || F->get().name == "resource_name" || F->get().name == "resource_path" || F->get().name == "resource_local_to_scene") {
for (const PropertyInfo &pi : plist) {
if (pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene") {
continue;
}
if (F->get().usage != PROPERTY_USAGE_DEFAULT) {
if (pi.usage != PROPERTY_USAGE_DEFAULT) {
continue;
}
PropertyInfo prop = F->get();
PropertyInfo prop = pi;
prop.name = itos(i) + "/" + prop.name;
p_list->push_back(prop);

View file

@ -463,13 +463,13 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
tile_data->get_property_list(&list);
HashMap<String, int> counts; // Counts the number of time a property appears (useful for groups that may appear more than once)
for (List<PropertyInfo>::Element *E_property = list.front(); E_property; E_property = E_property->next()) {
for (const PropertyInfo &property : list) {
// Don't show category for TileData.
if (E_property->get().usage & PROPERTY_USAGE_CATEGORY) {
if (property.usage & PROPERTY_USAGE_CATEGORY) {
continue;
}
const String &property_string = E_property->get().name;
const String &property_string = property.name;
if (!tile_data->is_allowing_transform() && (property_string == "flip_h" || property_string == "flip_v" || property_string == "transpose")) {
continue;
}
@ -480,7 +480,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro
counts[property_string] += 1;
}
PropertyInfo stored_property_info = E_property->get();
PropertyInfo stored_property_info = property;
stored_property_info.usage |= PROPERTY_USAGE_STORAGE; // Ignore the storage flag in comparing properties.
PropertyId id = { counts[property_string], property_string };

View file

@ -222,8 +222,7 @@ void VersionControlEditorPlugin::_refresh_commit_list() {
List<EditorVCSInterface::Commit> commit_info_list = EditorVCSInterface::get_singleton()->get_previous_commits(commit_list_size_button->get_selected_metadata());
for (List<EditorVCSInterface::Commit>::Element *e = commit_info_list.front(); e; e = e->next()) {
EditorVCSInterface::Commit commit = e->get();
for (const EditorVCSInterface::Commit &commit : commit_info_list) {
TreeItem *item = commit_list->create_item();
// Only display the first line of a commit message
@ -370,8 +369,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() {
unstaged_files->get_root()->clear_children();
List<EditorVCSInterface::StatusFile> status_files = EditorVCSInterface::get_singleton()->get_modified_files_data();
for (List<EditorVCSInterface::StatusFile>::Element *E = status_files.front(); E; E = E->next()) {
EditorVCSInterface::StatusFile sf = E->get();
for (const EditorVCSInterface::StatusFile &sf : status_files) {
if (sf.area == EditorVCSInterface::TREE_AREA_STAGED) {
_add_new_item(staged_files, sf.file_path, sf.change_type);
} else if (sf.area == EditorVCSInterface::TREE_AREA_UNSTAGED) {

View file

@ -4421,8 +4421,8 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
for (const VisualShader::Connection &E : conns) {
if (E.from_node == F || E.to_node == F) {
bool cancel = false;
for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) {
if (R->get().from_node == E.from_node && R->get().from_port == E.from_port && R->get().to_node == E.to_node && R->get().to_port == E.to_port) {
for (const VisualShader::Connection &R : used_conns) {
if (R.from_node == E.from_node && R.from_port == E.from_port && R.to_node == E.to_node && R.to_port == E.to_port) {
cancel = true; // to avoid ERR_ALREADY_EXISTS warning
break;
}