Fix non-const iterators in const methods

This commit is contained in:
Lightning_A 2021-08-09 09:03:45 -06:00
parent 3e1b630461
commit e4dfa69bcf
2 changed files with 6 additions and 9 deletions

View file

@ -702,8 +702,7 @@ public:
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
int key = 0; int key = 0;
for (float &F : E->value()) { for (const float &key_ofs : E->value()) {
float key_ofs = F;
if (from != key_ofs) { if (from != key_ofs) {
key++; key++;
continue; continue;
@ -728,8 +727,7 @@ public:
bool change_notify_deserved = false; bool change_notify_deserved = false;
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
int track = E->key(); int track = E->key();
for (float &F : E->value()) { for (const float &key_ofs : E->value()) {
float key_ofs = F;
int key = animation->track_find_key(track, key_ofs, true); int key = animation->track_find_key(track, key_ofs, true);
ERR_FAIL_COND_V(key == -1, false); ERR_FAIL_COND_V(key == -1, false);
@ -986,8 +984,7 @@ public:
bool _get(const StringName &p_name, Variant &r_ret) const { bool _get(const StringName &p_name, Variant &r_ret) const {
for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) {
int track = E->key(); int track = E->key();
for (float &F : E->value()) { for (const float &key_ofs : E->value()) {
float key_ofs = F;
int key = animation->track_find_key(track, key_ofs, true); int key = animation->track_find_key(track, key_ofs, true);
ERR_CONTINUE(key == -1); ERR_CONTINUE(key == -1);
@ -1137,7 +1134,7 @@ public:
same_key_type = false; same_key_type = false;
} }
for (float &F : E->value()) { for (const float &F : E->value()) {
int key = animation->track_find_key(track, F, true); int key = animation->track_find_key(track, F, true);
ERR_FAIL_COND(key == -1); ERR_FAIL_COND(key == -1);
if (first_key < 0) { if (first_key < 0) {

View file

@ -978,7 +978,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) { for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
for (int i = 0; i < E->get().connections.size(); i++) { 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) { if (output == p_output_node) {
return CONNECTION_ERROR_CONNECTION_EXISTS; return CONNECTION_ERROR_CONNECTION_EXISTS;
} }
@ -990,7 +990,7 @@ AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node
void AnimationNodeBlendTree::get_node_connections(List<NodeConnection> *r_connections) const { void AnimationNodeBlendTree::get_node_connections(List<NodeConnection> *r_connections) const {
for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) { for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
for (int i = 0; i < E->get().connections.size(); i++) { 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()) { if (output != StringName()) {
NodeConnection nc; NodeConnection nc;
nc.input_node = E->key(); nc.input_node = E->key();