diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2021-07-24 15:46:25 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2021-07-25 12:22:25 +0200 |
commit | ac3322b0af8f23e8e2dac8111200bc69b5604c9f (patch) | |
tree | 59a079f13b5c03c2dd3328a26c55f3618e6014f6 /editor/plugins | |
parent | a0f7f42b842462646281f5c4c9a8db070e034adc (diff) |
Use const references where possible for List range iterators
Diffstat (limited to 'editor/plugins')
22 files changed, 121 insertions, 121 deletions
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index ab11680e2f..ad2d9866fa 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,14 +72,14 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven List<StringName> names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; @@ -373,7 +373,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 3fb90eb4ff..49fcac512b 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -96,14 +96,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope @@ -295,7 +295,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 705a1d0fc0..c94014944c 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -121,7 +121,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> nodes; blend_tree->get_node_list(&nodes); - for (StringName &E : nodes) { + for (const StringName &E : nodes) { GraphNode *node = memnew(GraphNode); graph->add_child(node); @@ -155,7 +155,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<PropertyInfo> pinfo; agnode->get_parameter_list(&pinfo); - for (PropertyInfo &F : pinfo) { + for (const PropertyInfo &F : pinfo) { if (!(F.usage & PROPERTY_USAGE_EDITOR)) { continue; } @@ -212,7 +212,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> anims; ap->get_animation_list(&anims); - for (StringName &F : anims) { + for (const StringName &F : anims) { mb->get_popup()->add_item(F); options.push_back(F); } @@ -246,7 +246,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; @@ -274,7 +274,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -394,7 +394,7 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (AnimationNodeBlendTree::NodeConnection &E : conns) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { if (E.output_node == p_which || E.input_node == p_which) { undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E.input_node, E.input_index, E.output_node); } @@ -423,7 +423,7 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { undo_redo->create_action(TTR("Delete Node(s)")); - for (StringName &F : to_erase) { + for (const StringName &F : to_erase) { _delete_request(F); } @@ -517,7 +517,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano List<StringName> animations; player->get_animation_list(&animations); - for (StringName &E : animations) { + for (const StringName &E : animations) { Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); @@ -718,7 +718,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (AnimationNodeBlendTree::NodeConnection &E : conns) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { float activity = 0; StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { @@ -828,7 +828,7 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 1bdbc2980c..4ba9147955 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -350,7 +350,7 @@ void AnimationPlayerEditor::_animation_load() { List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); - for (String &E : extensions) { + for (const String &E : extensions) { file->add_filter("*." + E + " ; " + E.to_upper()); } @@ -584,7 +584,7 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->clear(); blend_editor.next->add_item("", i); - for (StringName &to : anims) { + for (const StringName &to : anims) { TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); blend->set_editable(1, true); @@ -829,7 +829,7 @@ void AnimationPlayerEditor::_update_player() { } int active_idx = -1; - for (StringName &E : animlist) { + for (const StringName &E : animlist) { Ref<Texture2D> icon; if (E == player->get_autoplay()) { if (E == "RESET") { @@ -965,7 +965,7 @@ void AnimationPlayerEditor::_animation_duplicate() { Ref<Animation> new_anim = memnew(Animation); List<PropertyInfo> plist; anim->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_STORAGE) { new_anim->set(E.name, anim->get(E.name)); } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index bee6af3cbb..a1f96f21bf 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -93,14 +93,14 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope @@ -318,7 +318,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv float best_d_x = 1e20; float best_d_y = 1e20; - for (StringName &E : nodes) { + for (const StringName &E : nodes) { if (E == selected_node) { continue; } @@ -409,7 +409,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -606,7 +606,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } //pre pass nodes so we know the rectangles - for (StringName &E : nodes) { + for (const StringName &E : nodes) { Ref<AnimationNode> anode = state_machine->get_node(E); String name = E; bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 67d5600a3c..cd84be0c25 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -215,7 +215,7 @@ Vector<String> AnimationTreeEditor::get_animation_list() { List<StringName> anims; ap->get_animation_list(&anims); Vector<String> ret; - for (StringName &E : anims) { + for (const StringName &E : anims) { ret.push_back(E); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8b9e76b402..869a582d96 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -399,7 +399,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) { Transform2D to_snap_transform = Transform2D(); List<const CanvasItem *> exceptions = List<const CanvasItem *>(); - for (CanvasItem *E : p_other_nodes_exceptions) { + for (const CanvasItem *E : p_other_nodes_exceptions) { exceptions.push_back(E); } if (p_self_canvas_item) { @@ -842,7 +842,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); if (commit_bones) { - for (Dictionary &F : se->pre_drag_bones_undo_state) { + for (const Dictionary &F : se->pre_drag_bones_undo_state) { canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); @@ -3555,7 +3555,7 @@ void CanvasItemEditor::_draw_hover() { Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4); // Rectify the position to avoid overlapping items - for (Rect2 &E : previous_rects) { + for (const Rect2 &E : previous_rects) { if (E.intersects(Rect2(pos, item_size))) { pos.y = E.get_position().y - item_size.y; } @@ -4699,7 +4699,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->create_action(TTR("Paste Pose")); - for (PoseClipboard &E : pose_clipboard) { + for (const PoseClipboard &E : pose_clipboard) { Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E.id)); if (!n2d) { continue; diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 7e0eb89359..6f246c1661 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -253,7 +253,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (String &E : ext) { + for (const String &E : ext) { file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 19204e3bf8..81c340e9a4 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -490,7 +490,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set<String> control_flow_keywords; Set<String> keywords; - for (String &E : kwors) { + for (const String &E : kwors) { if (scr->get_language()->is_control_flow_keyword(E)) { control_flow_keywords.insert(E); } else { diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 4412d51077..5184e837ce 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -361,7 +361,7 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (String &E : ext) { + for (const String &E : ext) { file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 32d5865d0b..94966d4fe6 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -265,7 +265,7 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref<Texture2D> texture = mat->get_texture_by_name(E.name); @@ -309,7 +309,7 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -346,7 +346,7 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -383,7 +383,7 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -420,7 +420,7 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -457,7 +457,7 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 393aaff207..2138f943da 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -4746,7 +4746,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (Face3 &f : faces) { + for (const Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 0cb5a2e1e4..cbea2405b8 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -181,13 +181,13 @@ void ResourcePreloaderEditor::_update_library() { preloader->get_resource_list(&rnames); List<String> names; - for (StringName &E : rnames) { + for (const StringName &E : rnames) { names.push_back(E); } names.sort(); - for (String &E : names) { + for (const String &E : names) { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 95e23d0c57..ed91f174d1 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -70,7 +70,7 @@ void EditorPropertyRootMotion::_node_assign() { List<StringName> animations; player->get_animation_list(&animations); - for (StringName &E : animations) { + for (const StringName &E : animations) { Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index ab783c87e9..668a15da37 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -103,7 +103,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); @@ -115,7 +115,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (StringName &E : global_classes) { + for (const StringName &E : global_classes) { highlighter->add_keyword_color(E, usertype_color); } @@ -134,7 +134,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; script->get_language()->get_core_type_words(&core_types); - for (String &E : core_types) { + for (const String &E : core_types) { highlighter->add_keyword_color(E, basetype_color); } @@ -143,7 +143,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); - for (String &E : keywords) { + for (const String &E : keywords) { if (script->get_language()->is_control_flow_keyword(E)) { highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -157,7 +157,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { String name = E.name; if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; @@ -170,7 +170,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (String &E : clist) { + for (const String &E : clist) { highlighter->add_member_keyword_color(E, member_variable_color); } } @@ -179,7 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; script->get_language()->get_comment_delimiters(&comments); - for (String &comment : comments) { + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, comment_color, end == ""); @@ -189,7 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; script->get_language()->get_string_delimiters(&strings); - for (String &string : strings) { + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, string_color, end == ""); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index f9a0f307c3..65459d159d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -50,7 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n List<Connection> all_connections; p_nodes[i]->get_signals_connected_to_this(&all_connections); - for (Connection &connection : all_connections) { + for (const Connection &connection : all_connections) { if (connection.callable.get_method() != p_method) { continue; } @@ -114,7 +114,7 @@ Vector<String> ScriptTextEditor::get_functions() { if (script->get_language()->validate(text, script->get_path(), &fnc)) { //if valid rewrite functions to latest functions.clear(); - for (String &E : fnc) { + for (const String &E : fnc) { functions.push_back(E); } } @@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> strings; script->get_language()->get_string_delimiters(&strings); text_edit->clear_string_delimiters(); - for (String &string : strings) { + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); text_edit->add_string_delimiter(beg, end, end == ""); @@ -210,7 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> comments; script->get_language()->get_comment_delimiters(&comments); text_edit->clear_comment_delimiters(); - for (String &comment : comments) { + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); text_edit->add_comment_delimiter(beg, end, end == ""); @@ -413,7 +413,7 @@ void ScriptTextEditor::_validate_script() { } functions.clear(); - for (String &E : fnc) { + for (const String &E : fnc) { functions.push_back(E); } script_is_valid = true; @@ -428,7 +428,7 @@ void ScriptTextEditor::_validate_script() { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); - for (Connection &connection : missing_connections) { + for (const Connection &connection : missing_connections) { String base_path = base->get_name(); String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object())); String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())); @@ -450,7 +450,7 @@ void ScriptTextEditor::_validate_script() { // Add script warnings. warnings_panel->push_table(3); - for (ScriptLanguage::Warning &w : warnings) { + for (const ScriptLanguage::Warning &w : warnings) { Dictionary ignore_meta; ignore_meta["line"] = w.start_line; ignore_meta["code"] = w.string_code.to_lower(); @@ -480,7 +480,7 @@ void ScriptTextEditor::_validate_script() { errors_panel->clear(); errors_panel->push_table(2); - for (ScriptLanguage::ScriptError &err : errors) { + for (const ScriptLanguage::ScriptError &err : errors) { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); @@ -501,7 +501,7 @@ void ScriptTextEditor::_validate_script() { if (errors.is_empty()) { te->set_line_background_color(i, Color(0, 0, 0, 0)); } else { - for (ScriptLanguage::ScriptError &E : errors) { + for (const ScriptLanguage::ScriptError &E : errors) { bool error_line = i == E.line - 1; te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0)); if (error_line) { @@ -900,7 +900,7 @@ void ScriptTextEditor::_update_connected_methods() { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); - for (Connection &connection : connections) { + for (const Connection &connection : connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } @@ -1275,7 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() { List<String> comment_delimiters; script->get_language()->get_comment_delimiters(&comment_delimiters); - for (String &script_delimiter : comment_delimiters) { + for (const String &script_delimiter : comment_delimiters) { if (script_delimiter.find(" ") == -1) { delimiter = script_delimiter; break; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 6c589ee07c..95870a0f3c 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -118,7 +118,7 @@ void ShaderTextEditor::_load_theme_settings() { const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); - for (String &E : keywords) { + for (const String &E : keywords) { if (ShaderLanguage::is_control_flow_keyword(E)) { syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -144,7 +144,7 @@ void ShaderTextEditor::_load_theme_settings() { const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); - for (String &E : built_ins) { + for (const String &E : built_ins) { syntax_highlighter->add_keyword_color(E, member_variable_color); } diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 486a40a4fd..a5d0ebbc12 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -788,7 +788,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : anim_names) { + for (const StringName &E : anim_names) { String name = E; TreeItem *it = animations->create_item(anim_root); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 34227ee894..b277f2ab42 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -144,7 +144,7 @@ void TextureRegionEditor::_region_draw() { } } } else if (snap_mode == SNAP_AUTOSLICE) { - for (Rect2 &r : autoslice_cache) { + for (const Rect2 &r : autoslice_cache) { Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), @@ -327,7 +327,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { Vector2 point = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y)); - for (Rect2 &E : autoslice_cache) { + for (const Rect2 &E : autoslice_cache) { if (E.has_point(point)) { rect = E; if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 991c298caa..df6e9e6614 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -65,7 +65,7 @@ void ThemeItemImportTree::_update_items_tree() { tree_icon_items.clear(); tree_stylebox_items.clear(); - for (StringName &E : types) { + for (const StringName &E : types) { String type_name = (String)E; TreeItem *type_node = import_items_tree->create_item(root); @@ -93,7 +93,7 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_has_filtered_items = false; - for (StringName &F : names) { + for (const StringName &F : names) { String item_name = (String)F; bool is_item_matching_filter = (item_name.findn(filter_text) > -1); if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) { @@ -182,7 +182,7 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_any_checked_with_data = false; filtered_names.sort_custom<StringName::AlphCompare>(); - for (StringName &F : filtered_names) { + for (const StringName &F : filtered_names) { TreeItem *item_node = import_items_tree->create_item(data_type_node); item_node->set_meta("_can_be_imported", true); item_node->set_text(0, F); @@ -1236,7 +1236,7 @@ void ThemeItemEditorDialog::_update_edit_types() { bool item_reselected = false; edit_type_list->clear(); int e_idx = 0; - for (StringName &E : theme_types) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); @@ -1318,7 +1318,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1339,7 +1339,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1360,7 +1360,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1381,7 +1381,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1402,7 +1402,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1423,7 +1423,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1507,7 +1507,7 @@ void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, edited_theme->_freeze_change_propagation(); edited_theme->get_theme_item_list(p_data_type, p_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { edited_theme->clear_theme_item(p_data_type, E, p_item_type); } @@ -1526,7 +1526,7 @@ void ThemeItemEditorDialog::_remove_class_items() { names.clear(); Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (edited_theme->has_theme_item_nocheck(data_type, E, edited_item_type)) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } @@ -1550,7 +1550,7 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } @@ -1574,7 +1574,7 @@ void ThemeItemEditorDialog::_remove_all_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } } @@ -1927,7 +1927,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { import_another_theme_dialog->set_title(TTR("Select Another Theme Resource:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); - for (String &E : ext) { + for (const String &E : ext) { import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); } import_another_file_hb->add_child(import_another_theme_dialog); @@ -1969,7 +1969,7 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { names.sort_custom<StringName::AlphCompare>(); Vector<StringName> unique_names; - for (StringName &E : names) { + for (const StringName &E : names) { // Filter out undesired values. if (!p_filter.is_subsequence_ofi(String(E))) { continue; @@ -2132,7 +2132,7 @@ void ThemeTypeEditor::_update_type_list() { bool item_reselected = false; int e_idx = 0; - for (StringName &E : theme_types) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); @@ -2182,7 +2182,7 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ (Theme::get_default().operator->()->*get_list_func)(default_type, &names); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { items[E] = false; } } @@ -2191,7 +2191,7 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ names.clear(); (edited_theme.operator->()->*get_list_func)(p_type_name, &names); names.sort_custom<StringName::AlphCompare>(); - for (StringName &E : names) { + for (const StringName &E : names) { items[E] = true; } } @@ -2203,7 +2203,7 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ keys.sort_custom<StringName::AlphCompare>(); OrderedHashMap<StringName, bool> ordered_items; - for (StringName &E : keys) { + for (const StringName &E : keys) { ordered_items[E] = items[E]; } @@ -2580,7 +2580,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_icon_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_icon(E, edited_type)) { edited_theme->set_icon(E, edited_type, Ref<Texture2D>()); } @@ -2589,7 +2589,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_stylebox_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_stylebox(E, edited_type)) { edited_theme->set_stylebox(E, edited_type, Ref<StyleBox>()); } @@ -2598,7 +2598,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_font_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_font(E, edited_type)) { edited_theme->set_font(E, edited_type, Ref<Font>()); } @@ -2607,7 +2607,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_font_size_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_font_size(E, edited_type)) { edited_theme->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, default_type)); } @@ -2616,7 +2616,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_color_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_color(E, edited_type)) { edited_theme->set_color(E, edited_type, Theme::get_default()->get_color(E, default_type)); } @@ -2625,7 +2625,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_constant_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_constant(E, edited_type)) { edited_theme->set_constant(E, edited_type, Theme::get_default()->get_constant(E, default_type)); } @@ -2882,7 +2882,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<StringName> names; edited_theme->get_stylebox_list(edited_type, &names); List<Ref<StyleBox>> styleboxes; - for (StringName &E : names) { + for (const StringName &E : names) { if (E == leading_stylebox.item_name) { continue; } @@ -2895,7 +2895,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<PropertyInfo> props; leading_stylebox.stylebox->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -3301,7 +3301,7 @@ ThemeEditor::ThemeEditor() { preview_scene_dialog->set_title(TTR("Select UI Scene:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); - for (String &E : ext) { + for (const String &E : ext) { preview_scene_dialog->add_filter("*." + E + "; Scene"); } main_hs->add_child(preview_scene_dialog); @@ -3343,11 +3343,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_font_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_font_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (font_item == edited_theme->get_font(F, E)) { belongs_to_theme = true; break; @@ -3360,11 +3360,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_stylebox_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_stylebox_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (stylebox_item == edited_theme->get_stylebox(F, E)) { belongs_to_theme = true; break; @@ -3377,11 +3377,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_icon_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_icon_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (icon_item == edited_theme->get_icon(F, E)) { belongs_to_theme = true; break; diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index ab26e1c380..432f48fa85 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -303,7 +303,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro } // Add only properties that are common to all tiles. - for (PLData *E : data_list) { + for (const PLData *E : data_list) { if (E->uses == tiles.size()) { p_list->push_back(E->property_info); } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 7e3244dddf..46818afe45 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -666,7 +666,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); - for (VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : connections) { if (E.to_node == p_id && E.to_port == j) { port_left_used = true; } @@ -899,7 +899,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->set_syntax_highlighter(expression_syntax_highlighter); expression_box->add_theme_color_override("background_color", background_color); - for (String &E : VisualShaderEditor::get_singleton()->keyword_list) { + for (const String &E : VisualShaderEditor::get_singleton()->keyword_list) { if (ShaderLanguage::is_control_flow_keyword(E)) { expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -1470,7 +1470,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : connections) { int from = E.from_node; int from_idx = E.from_port; int to = E.to_node; @@ -1634,7 +1634,7 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -1708,7 +1708,7 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -1757,7 +1757,7 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -2518,7 +2518,7 @@ void VisualShaderEditor::_nodes_dragged() { undo_redo->create_action(TTR("Node(s) Moved")); - for (DragOp &E : drag_buffer) { + for (const DragOp &E : drag_buffer) { undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.to); undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.from); undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.to); @@ -2544,7 +2544,7 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.to_node == to && E.to_port == p_to_index) { undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -2598,7 +2598,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { visual_shader->get_node_connections(type, &conns); for (const int &F : p_nodes) { - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == F || E.to_node == F) { undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } @@ -2639,7 +2639,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { List<VisualShader::Connection> used_conns; for (const int &F : p_nodes) { - for (VisualShader::Connection &E : conns) { + 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()) { @@ -3094,7 +3094,7 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); - for (String &E : keyword_list) { + for (const String &E : keyword_list) { if (ShaderLanguage::is_control_flow_keyword(E)) { syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -3249,7 +3249,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in List<VisualShader::Connection> conns; visual_shader->get_node_connections(pasted_type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (unsupported_set.has(E.from_node) || unsupported_set.has(E.to_node)) { continue; } @@ -3399,7 +3399,7 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == id) { if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -3445,7 +3445,7 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_ if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == id) { if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; @@ -4825,7 +4825,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<PropertyInfo> pinfo; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { for (int i = 0; i < properties.size(); i++) { if (E.name == String(properties[i])) { pinfo.push_back(E); @@ -4894,7 +4894,7 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { VisualShader::Type type = VisualShader::Type(i); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.to_node == VisualShader::NODE_ID_OUTPUT) { undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } @@ -4918,7 +4918,7 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { List<PropertyInfo> props; visual_shader->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (E.name.begins_with("flags/") || E.name.begins_with("modes/")) { undo_redo->add_undo_property(visual_shader.ptr(), E.name, visual_shader->get(E.name)); } @@ -5024,7 +5024,7 @@ void VisualShaderNodePortPreview::_shader_changed() { if (src_mat && src_mat->get_shader().is_valid()) { List<PropertyInfo> params; src_mat->get_shader()->get_param_list(¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { material->set(E.name, src_mat->get(E.name)); } } |