From fe4653c30e64d6381f41a5de4a1d23edbb28c750 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 24 Jul 2016 17:30:00 -0400 Subject: [PATCH] Fix crash when BuildMenus() is run with elements in the favorites menu --- src/gui/game/GameModel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 005d63c4de..a4f2cb4355 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -233,9 +233,11 @@ void GameModel::BuildMenus() activeToolIdentifiers[3] = regularToolset[3]->GetIdentifier(); //Empty current menus - for(std::vector::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter) + for (size_t i = 0; i < menuList.size(); i++) { - delete *iter; + if (i == SC_FAVORITES) + menuList[i]->ClearTools(); + delete menuList[i]; } menuList.clear(); toolList.clear();