From e4dfa69bcf58e4d50acdde32c590364e43fce3ab Mon Sep 17 00:00:00 2001 From: Lightning_A Date: Mon, 9 Aug 2021 09:03:45 -0600 Subject: [PATCH] Fix non-const iterators in const methods --- editor/animation_track_editor.cpp | 11 ++++------- scene/animation/animation_blend_tree.cpp | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 324237ff82a..76e71a10306 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -702,8 +702,7 @@ public: for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { if (from != key_ofs) { key++; continue; @@ -728,8 +727,7 @@ public: bool change_notify_deserved = false; for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +984,7 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (float &F : E->value()) { - float key_ofs = F; + for (const float &key_ofs : E->value()) { int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,7 +1134,7 @@ public: same_key_type = false; } - for (float &F : E->value()) { + for (const float &F : E->value()) { int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index af186072ac9..c5f36bb98d2 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -978,7 +978,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node for (Map::Element *E = nodes.front(); E; E = E->next()) { for (int i = 0; i < E->get().connections.size(); i++) { - StringName output = E->get().connections[i]; + const StringName output = E->get().connections[i]; if (output == p_output_node) { return CONNECTION_ERROR_CONNECTION_EXISTS; } @@ -990,7 +990,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node void AnimationNodeBlendTree::get_node_connections(List *r_connections) const { for (Map::Element *E = nodes.front(); E; E = E->next()) { for (int i = 0; i < E->get().connections.size(); i++) { - StringName output = E->get().connections[i]; + const StringName output = E->get().connections[i]; if (output != StringName()) { NodeConnection nc; nc.input_node = E->key();