From ae093dba2fb97124bb4af3eaf4070b46f07dfd74 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 16 May 2002 09:24:40 +0000 Subject: make a new autoRaiseDelay value take effect without having to restart --- src/BaseDisplay.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/BaseDisplay.cc') 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); } -- cgit v1.2.3