From 5daf6022567a37cc434ac0bbd6916029a9984fda Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 29 Nov 2019 12:26:17 +0400 Subject: [PATCH] Fix iterator usage when destroying cell borders (bug #5218) --- CHANGELOG.md | 1 + components/terrain/cellborder.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de53c3a9db..8ceffc8f1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,6 +177,7 @@ Bug #5210: AiActivate allows actors to open dialogue and inventory windows Bug #5211: Screen fades in if the first loaded save is in interior cell Bug #5213: SameFaction script function is broken + Bug #5218: Crash when disabling ToggleBorders Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/components/terrain/cellborder.cpp b/components/terrain/cellborder.cpp index 64434727eb..6eabadf92d 100644 --- a/components/terrain/cellborder.cpp +++ b/components/terrain/cellborder.cpp @@ -91,8 +91,9 @@ void CellBorder::destroyCellBorderGeometry(int x, int y) void CellBorder::destroyCellBorderGeometry() { - for (CellGrid::iterator it = mCellBorderNodes.begin(); it != mCellBorderNodes.end(); ++it) - destroyCellBorderGeometry(it->first.first,it->first.second); + for (const auto& v : mCellBorderNodes) + mRoot->removeChild(v.second); + mCellBorderNodes.clear(); } }