aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/menu/control.cpp7
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;
}