diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-12-25 19:24:53 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:50 +0100 |
commit | 08241dfab34a37fb94707311def70d1ccaac702d (patch) | |
tree | 686b9c8e157227311d1ef2dbbfb59e40b525ae62 /src/menu | |
parent | 88cc0c80d70ecb4165651e1ea1456044e7639264 (diff) | |
download | usdx-08241dfab34a37fb94707311def70d1ccaac702d.tar.gz usdx-08241dfab34a37fb94707311def70d1ccaac702d.tar.xz usdx-08241dfab34a37fb94707311def70d1ccaac702d.zip |
menu/control: ensure safe destruction of the slaves
Diffstat (limited to 'src/menu')
-rw-r--r-- | src/menu/control.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
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<Control*>::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<Control*>::iterator next = slaves.begin(), it = next++; + it != slaves.end(); it = next++) { delete *it; } |