diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-02-20 18:20:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-20 18:20:23 +0100 |
commit | 132e2f458df7a3551a251d68afeccd0362ca6be2 (patch) | |
tree | a1665bbbba3655b69b7cfbc831df912bed72de96 /core/math | |
parent | 643af210b1b96b17b33f9bdb8d6921b18145ea47 (diff) | |
parent | c496781bf6dda3484b470d1e6d855bd095e71e28 (diff) |
Merge pull request #26015 from hedin-hiervard/master
fixed AStar improper point deletion (leads to crash)
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/a_star.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index b885a06834..21ec5218b7 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -97,11 +97,14 @@ void AStar::remove_point(int p_id) { Point *p = points[p_id]; - for (Set<Point *>::Element *E = p->neighbours.front(); E; E = E->next()) { - - Segment s(p_id, E->get()->id); - segments.erase(s); - E->get()->neighbours.erase(p); + Map<int, Point *>::Element *PE = points.front(); + while (PE) { + for (Set<Point *>::Element *E = PE->get()->neighbours.front(); E; E = E->next()) { + Segment s(p_id, E->get()->id); + segments.erase(s); + E->get()->neighbours.erase(p); + } + PE = PE->next(); } memdelete(p); |