From 9255fef52c78ad0fbc457af550e74ca679567773 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 20 Apr 2007 23:00:38 +0000 Subject: Microsoft's STL iterators are not behaving correctly. Fixing a bit the way we work with them. --- lib/TaskMan.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 183b162..b31d2cd 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -351,7 +351,9 @@ void TaskMan::RemoveFromWatches(Task * t) { for (std::vector::iterator p = w4ha.begin(); p != w4ha.end(); p++) { if (p->T == t) { w4ha.erase(p); - p--; + p = w4ha.begin(); + if (w4ha.empty()) + break; } } } @@ -360,7 +362,9 @@ void TaskMan::RemoveFromWatches(Task * t) { for (std::vector::iterator p = w4pr.begin(); p != w4pr.end(); p++) { if (p->T == t) { w4pr.erase(p); - p--; + p = w4pr.begin(); + if (w4pr.empty()) + break; } } } @@ -369,7 +373,9 @@ void TaskMan::RemoveFromWatches(Task * t) { for (std::vector::iterator p = w4to.begin(); p != w4to.end(); p++) { if (p->T == t) { w4to.erase(p); - p--; + p = w4to.begin(); + if (w4to.empty()) + break; } } } @@ -382,10 +388,14 @@ void TaskMan::RemoveFromWatches(Task * t) { TaskList.erase(p); number--; p = TaskList.begin(); + if (TaskList.empty()) + break; } else if ((*p) == t) { TaskList.erase(p); number--; p = TaskList.begin(); + if (TaskList.empty()) + break; } } } @@ -397,7 +407,9 @@ void TaskMan::RemoveTimeout(Task * t) { for (std::vector::iterator p = w4to.begin(); p != w4to.end(); p++) { if (p->T == t) { w4to.erase(p); - p--; + p = w4to.begin(); + if (w4to.empty()) + break; } } } -- cgit v1.2.3