From 08241dfab34a37fb94707311def70d1ccaac702d Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 25 Dec 2011 19:24:53 +0100 Subject: menu/control: ensure safe destruction of the slaves --- src/menu/control.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/menu') diff --git a/src/menu/control.cpp b/src/menu/control.cpp index bea054ee..c1c91fa3 100644 --- a/src/menu/control.cpp +++ b/src/menu/control.cpp @@ -38,8 +38,11 @@ namespace usdx Control::~Control() { - for (std::list::iterator it = - slaves.begin(); it != slaves.end(); it++) { + // you need the next iterator to be able to produce the next value after + // removing it (each control, will be issue a request to remove it self + // from the list) + for (std::list::iterator next = slaves.begin(), it = next++; + it != slaves.end(); it = next++) { delete *it; } -- cgit v1.2.3