diff --git a/src/gui/elementsearch/ElementSearchActivity.cpp b/src/gui/elementsearch/ElementSearchActivity.cpp index b14ff6044..7a1b8581a 100644 --- a/src/gui/elementsearch/ElementSearchActivity.cpp +++ b/src/gui/elementsearch/ElementSearchActivity.cpp @@ -95,9 +95,9 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st void ElementSearchActivity::searchTools(String query) { firstResult = NULL; - for(std::vector::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter != end; ++iter) { - delete *iter; - RemoveComponent(*iter); + for (auto &toolButton : toolButtons) { + RemoveComponent(toolButton); + delete toolButton; } toolButtons.clear();