From ac3322b0af8f23e8e2dac8111200bc69b5604c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 24 Jul 2021 15:46:25 +0200 Subject: Use const references where possible for List range iterators --- scene/2d/physics_body_2d.cpp | 2 +- scene/2d/tile_map.cpp | 10 ++++----- scene/3d/gpu_particles_collision_3d.cpp | 2 +- scene/3d/mesh_instance_3d.cpp | 2 +- scene/3d/physics_body_3d.cpp | 2 +- scene/3d/skeleton_3d.cpp | 2 +- scene/3d/soft_body_3d.cpp | 2 +- scene/animation/animation_blend_tree.cpp | 4 ++-- scene/animation/animation_node_state_machine.cpp | 6 ++--- scene/animation/animation_player.cpp | 8 +++---- scene/animation/animation_tree.cpp | 8 +++---- scene/debugger/scene_debugger.cpp | 4 ++-- scene/gui/code_edit.cpp | 2 +- scene/gui/control.cpp | 28 ++++++++++++------------ scene/gui/file_dialog.cpp | 2 +- scene/gui/graph_edit.cpp | 10 ++++----- scene/gui/popup_menu.cpp | 4 ++-- scene/main/http_request.cpp | 4 ++-- scene/main/instance_placeholder.cpp | 4 ++-- scene/main/node.cpp | 16 +++++++------- scene/main/scene_tree.cpp | 4 ++-- scene/main/window.cpp | 2 +- scene/resources/curve.cpp | 4 ++-- scene/resources/material.cpp | 2 +- scene/resources/navigation_mesh.cpp | 4 ++-- scene/resources/packed_scene.cpp | 12 +++++----- scene/resources/resource_format_text.cpp | 4 ++-- scene/resources/sprite_frames.cpp | 2 +- scene/resources/syntax_highlighter.cpp | 2 +- scene/resources/theme.cpp | 2 +- scene/resources/tile_set.cpp | 10 ++++----- scene/resources/visual_shader.cpp | 4 ++-- 32 files changed, 87 insertions(+), 87 deletions(-) (limited to 'scene') diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 8709acf7f1..561207c24c 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -145,7 +145,7 @@ TypedArray PhysicsBody2D::get_collision_exceptions() { List exceptions; PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody2D *physics_body = Object::cast_to(obj); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4a15a1dc46..3932f3dc78 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1596,7 +1596,7 @@ void TileMap::set_light_mask(int p_light_mask) { // Occlusion: set light mask. CanvasItem::set_light_mask(p_light_mask); for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - for (RID F : E->get().canvas_items) { + for (const RID &F : E->get().canvas_items) { RenderingServer::get_singleton()->canvas_item_set_light_mask(F, get_light_mask()); } } @@ -1609,7 +1609,7 @@ void TileMap::set_material(const Ref &p_material) { // Update material for the whole tilemap. for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (RID F : q.canvas_items) { + for (const RID &F : q.canvas_items) { RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } @@ -1622,7 +1622,7 @@ void TileMap::set_use_parent_material(bool p_use_parent_material) { // Update use_parent_material for the whole tilemap. for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (RID F : q.canvas_items) { + for (const RID &F : q.canvas_items) { RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } @@ -1633,7 +1633,7 @@ void TileMap::set_texture_filter(TextureFilter p_texture_filter) { CanvasItem::set_texture_filter(p_texture_filter); for (Map::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (RID E : q.canvas_items) { + for (const RID &E : q.canvas_items) { RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E, RS::CanvasItemTextureFilter(p_texture_filter)); _make_quadrant_dirty(F); } @@ -1645,7 +1645,7 @@ void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) { CanvasItem::set_texture_repeat(p_texture_repeat); for (Map::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (RID E : q.canvas_items) { + for (const RID &E : q.canvas_items) { RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E, RS::CanvasItemTextureRepeat(p_texture_repeat)); _make_quadrant_dirty(F); } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 97b562837a..cc1b620025 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -397,7 +397,7 @@ Ref GPUParticlesCollisionSDF::bake() { bake_step_function(0, "Finding Meshes"); } - for (PlotMesh &pm : plot_meshes) { + for (const PlotMesh &pm : plot_meshes) { for (int i = 0; i < pm.mesh->get_surface_count(); i++) { if (pm.mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; //only triangles diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 93cd088418..9ca1d55d0b 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -94,7 +94,7 @@ void MeshInstance3D::_get_property_list(List *p_list) const { ls.sort(); - for (String &E : ls) { + for (const String &E : ls) { p_list->push_back(PropertyInfo(Variant::FLOAT, E, PROPERTY_HINT_RANGE, "-1,1,0.00001")); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 6736a4ec40..93ecb2cd3a 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -78,7 +78,7 @@ TypedArray PhysicsBody3D::get_collision_exceptions() { List exceptions; PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to(obj); diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index fb5e9639c7..9ce4c37457 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -264,7 +264,7 @@ void Skeleton3D::_notification(int p_what) { b.global_pose_override_amount = 0.0; } - for (ObjectID &E : b.nodes_bound) { + for (const ObjectID &E : b.nodes_bound) { Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); Node3D *node_3d = Object::cast_to(obj); diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 0d00d10d32..a7ff0842d2 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -592,7 +592,7 @@ Array SoftBody3D::get_collision_exceptions() { List exceptions; PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to(obj); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 495f60d4c9..4bddae3b14 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -1089,7 +1089,7 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons conns.resize(nc.size() * 3); int idx = 0; - for (NodeConnection &E : nc) { + for (const NodeConnection &E : nc) { conns[idx * 3 + 0] = E.input_node; conns[idx * 3 + 1] = E.input_index; conns[idx * 3 + 2] = E.output_node; @@ -1110,7 +1110,7 @@ void AnimationNodeBlendTree::_get_property_list(List *p_list) cons } names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { String name = E; if (name != "output") { p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 383d92d37f..bf53b554bf 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -512,7 +512,7 @@ void AnimationNodeStateMachine::get_parameter_list(List *r_list) c } advance_conditions.sort_custom(); - for (StringName &E : advance_conditions) { + for (const StringName &E : advance_conditions) { r_list->push_back(PropertyInfo(Variant::BOOL, E)); } } @@ -679,7 +679,7 @@ void AnimationNodeStateMachine::get_node_list(List *r_nodes) const { } nodes.sort_custom(); - for (StringName &E : nodes) { + for (const StringName &E : nodes) { r_nodes->push_back(E); } } @@ -902,7 +902,7 @@ void AnimationNodeStateMachine::_get_property_list(List *p_list) c } names.sort_custom(); - for (StringName &name : names) { + for (const StringName &name : names) { p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 0f557519b2..67b6205a65 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -176,7 +176,7 @@ void AnimationPlayer::_get_property_list(List *p_list) const { anim_names.sort(); - for (PropertyInfo &E : anim_names) { + for (const PropertyInfo &E : anim_names) { p_list->push_back(E); } @@ -1076,7 +1076,7 @@ void AnimationPlayer::get_animation_list(List *p_animations) const { anims.sort(); - for (String &E : anims) { + for (const String &E : anims) { p_animations->push_back(E); } } @@ -1118,7 +1118,7 @@ void AnimationPlayer::queue(const StringName &p_name) { Vector AnimationPlayer::get_queue() { Vector ret; - for (StringName &E : queued) { + for (const StringName &E : queued) { ret.push_back(E); } @@ -1502,7 +1502,7 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) { List al; get_animation_list(&al); - for (StringName &E : al) { + for (const StringName &E : al) { r_options->push_back(quote_style + String(E) + quote_style); } } diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index d277808e1f..00b847168d 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -76,7 +76,7 @@ void AnimationNode::get_child_nodes(List *r_child_nodes) { Dictionary cn = get_script_instance()->call("_get_child_nodes"); List keys; cn.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { ChildNode child; child.name = E; child.node = cn[E]; @@ -536,7 +536,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List sname; player->get_animation_list(&sname); - for (StringName &E : sname) { + for (const StringName &E : sname) { Ref anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); @@ -816,7 +816,7 @@ void AnimationTree::_process_graph(float p_delta) { { bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); - for (AnimationNode::AnimationState &as : state.animation_states) { + for (const AnimationNode::AnimationState &as : state.animation_states) { Ref a = as.animation; float time = as.time; float delta = as.delta; @@ -1369,7 +1369,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref children; node->get_child_nodes(&children); - for (AnimationNode::ChildNode &E : children) { + for (const AnimationNode::ChildNode &E : children) { _update_properties_for_node(p_base_path + E.name + "/", E.node); } } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 5012aed99a..ce2b320c96 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -292,7 +292,7 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { // Add base object properties. List pinfo; obj->get_property_list(&pinfo, true); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { properties.push_back(SceneDebuggerProperty(E, obj->get(E.name))); } @@ -452,7 +452,7 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) { } void SceneDebuggerTree::serialize(Array &p_arr) { - for (RemoteNode &n : nodes) { + for (const RemoteNode &n : nodes) { p_arr.push_back(n.child_count); p_arr.push_back(n.name); p_arr.push_back(n.type_name); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 6e3d0e2767..17fe8f4dca 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -2288,7 +2288,7 @@ void CodeEdit::_filter_code_completion_candidates() { TypedArray completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (ScriptCodeCompletionOption &E : code_completion_option_sources) { + for (const ScriptCodeCompletionOption &E : code_completion_option_sources) { Dictionary option; option["kind"] = E.kind; option["display_text"] = E.display; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index ae1f4b2f65..e3bfb2b40c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -343,7 +343,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_icon_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.icon_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -355,7 +355,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_stylebox_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.style_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -367,7 +367,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_font_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -379,7 +379,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_font_size_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_size_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -391,7 +391,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_color_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.color_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -403,7 +403,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_constant_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.constant_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -428,7 +428,7 @@ void Control::_validate_property(PropertyInfo &property) const { Vector unique_names; String hint_string; - for (StringName &E : names) { + for (const StringName &E : names) { // Skip duplicate values. if (unique_names.has(E)) { continue; @@ -793,7 +793,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E); } @@ -822,7 +822,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E); } @@ -830,7 +830,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return Theme::get_default()->get_theme_item(p_data_type, p_name, E); } @@ -848,7 +848,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -877,7 +877,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -885,7 +885,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -2580,7 +2580,7 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List } sn.sort_custom(); - for (StringName &E : sn) { + for (const StringName &E : sn) { r_options->push_back(quote_style + E + quote_style); } } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 67cb6f04a7..2e4204e171 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -552,7 +552,7 @@ void FileDialog::update_file_list() { bool match = patterns.is_empty(); String match_str; - for (String &E : patterns) { + for (const String &E : patterns) { if (files.front()->get().matchn(E)) { match_str = E; match = true; diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 8ad4d04b7f..1fac2b9129 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -217,7 +217,7 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S } bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { return true; } @@ -561,7 +561,7 @@ void GraphEdit::_top_layer_input(const Ref &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) { //check disconnect - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.from == gn->get_name() && E.from_port == j) { Node *to = get_node(String(E.to)); if (Object::cast_to(to)) { @@ -603,7 +603,7 @@ void GraphEdit::_top_layer_input(const Ref &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) { //check disconnect - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.to == gn->get_name() && E.to_port == j) { Node *fr = get_node(String(E.from)); if (Object::cast_to(fr)) { @@ -1001,7 +1001,7 @@ void GraphEdit::_minimap_draw() { // Draw node connections. Color activity_color = get_theme_color(SNAME("activity")); - for (Connection &E : connections) { + for (const Connection &E : connections) { NodePath fromnp(E.from); Node *from = get_node(fromnp); @@ -1500,7 +1500,7 @@ Array GraphEdit::_get_connection_list() const { List conns; get_connection_list(&conns); Array arr; - for (Connection &E : conns) { + for (const Connection &E : conns) { Dictionary d; d["from"] = E.from; d["from_port"] = E.from_port; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index ae3db4a983..7790a0970c 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -397,7 +397,7 @@ void PopupMenu::_gui_input(const Ref &p_event) { Ref m = p_event; if (m.is_valid()) { - for (Rect2 &E : autohide_areas) { + for (const Rect2 &E : autohide_areas) { if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E.has_point(m->get_position())) { _close_pressed(); return; @@ -751,7 +751,7 @@ void PopupMenu::_notification(int p_what) { Point2 mouse_pos = DisplayServer::get_singleton()->mouse_get_position(); mouse_pos -= get_position(); - for (Rect2 &E : autohide_areas) { + for (const Rect2 &E : autohide_areas) { if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E.has_point(mouse_pos)) { _close_pressed(); return; diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 588d4b67d5..2c6cefa771 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -220,7 +220,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { client->get_response_headers(&rheaders); response_headers.resize(0); downloaded.set(0); - for (String &E : rheaders) { + for (const String &E : rheaders) { response_headers.push_back(E); } @@ -235,7 +235,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { String new_request; - for (String &E : rheaders) { + for (const String &E : rheaders) { if (E.findn("Location: ") != -1) { new_request = E.substr(9, E.length()).strip_edges(); } diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index b7c6723cfc..b5ba1899ec 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -95,7 +95,7 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Refset_name(get_name()); int pos = get_index(); - for (PropSet &E : stored_values) { + for (const PropSet &E : stored_values) { scene->set(E.name, E.value); } @@ -114,7 +114,7 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) { Dictionary ret; PackedStringArray order; - for (PropSet &E : stored_values) { + for (const PropSet &E : stored_values) { ret[E.name] = E.value; if (p_with_order) { order.push_back(E.name); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 4b496d4761..f1e5574351 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1597,7 +1597,7 @@ Array Node::_get_groups() const { Array groups; List gi; get_groups(&gi); - for (GroupInfo &E : gi) { + for (const GroupInfo &E : gi) { groups.push_back(E.name); } @@ -1947,7 +1947,7 @@ Node *Node::_duplicate(int p_flags, Map *r_duplimap) const List plist; N->get()->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -1983,7 +1983,7 @@ Node *Node::_duplicate(int p_flags, Map *r_duplimap) const if (p_flags & DUPLICATE_GROUPS) { List gi; get_groups(&gi); - for (GroupInfo &E : gi) { + for (const GroupInfo &E : gi) { #ifdef TOOLS_ENABLED if ((p_flags & DUPLICATE_FROM_EDITOR) && !E.persistent) { continue; @@ -2073,7 +2073,7 @@ void Node::remap_node_resources(Node *p_node, const Map &p_resource_re List props; p_node->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -2099,7 +2099,7 @@ void Node::remap_nested_resources(RES p_resource, const Map &p_resourc List props; p_resource->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -2135,7 +2135,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { List conns; n->get_all_signal_connections(&conns); - for (Connection &E : conns) { + for (const Connection &E : conns) { if (E.flags & CONNECT_PERSIST) { //user connected NodePath p = p_original->get_path_to(n); @@ -2194,7 +2194,7 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) { List groups; get_groups(&groups); - for (GroupInfo &E : groups) { + for (const GroupInfo &E : groups) { p_node->add_to_group(E.name, E.persistent); } } @@ -2241,7 +2241,7 @@ void Node::_replace_connections_target(Node *p_new_target) { List cl; get_signals_connected_to_this(&cl); - for (Connection &c : cl) { + for (const Connection &c : cl) { if (c.flags & CONNECT_PERSIST) { c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method())); bool valid = p_new_target->has_method(c.callable.get_method()) || Ref