summaryrefslogtreecommitdiff
path: root/src/BaseDisplay.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/BaseDisplay.cc')
-rw-r--r--src/BaseDisplay.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc
index 28742e98..c99b2b16 100644
--- a/src/BaseDisplay.cc
+++ b/src/BaseDisplay.cc
@@ -462,10 +462,10 @@ void BaseDisplay::eventLoop(void) {
gettimeofday(&now, 0);
TimerList::iterator it;
- for (it = timerList.begin(); it != timerList.end(); ) {
+ for (it = timerList.begin(); it != timerList.end(); ++it) {
BTimer *timer = *it;
- ++it; // the timer may be removed from the list, so move ahead now
ASSERT(timer != NULL);
+
tm.tv_sec = timer->getStartTime().tv_sec +
timer->getTimeout().tv_sec;
tm.tv_usec = timer->getStartTime().tv_usec +
@@ -478,12 +478,16 @@ void BaseDisplay::eventLoop(void) {
timer->fireTimeout();
// restart the current timer so that the start time is updated
- if (! timer->doOnce())
+ if (! timer->doOnce()) {
+ // reorder
+ removeTimer(timer);
+ addTimer(timer);
timer->start();
- else {
+ } else
timer->stop();
-// delete timer; // USE THIS?
- }
+ it = timerList.begin(); // we no longer have any idea if the iterator is
+ // valid, but what was at the front() is no
+ // longer.
}
}
}
@@ -531,6 +535,7 @@ void BaseDisplay::addTimer(BTimer *timer) {
void BaseDisplay::removeTimer(BTimer *timer) {
+ ASSERT(timer != (BTimer *) 0);
timerList.remove(timer);
}