diff options
author | fluxgen <fluxgen> | 2002-05-23 09:48:22 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-05-23 09:48:22 (GMT) |
commit | b839dcaf1e5e11ce41b1e0e3d6c2d4d321fd236e (patch) | |
tree | 1292e58de5f2abc6892b11acc018f5b2c52e655a | |
parent | ea4c11a52e05844c3ebd99a6ee5b44a04852067b (diff) | |
download | fluxbox_paul-b839dcaf1e5e11ce41b1e0e3d6c2d4d321fd236e.zip fluxbox_paul-b839dcaf1e5e11ce41b1e0e3d6c2d4d321fd236e.tar.bz2 |
iterator fix
-rw-r--r-- | src/Timer.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/Timer.cc b/src/Timer.cc index 876e53f..79b0939 100644 --- a/src/Timer.cc +++ b/src/Timer.cc | |||
@@ -128,22 +128,24 @@ void BTimer::updateTimers(int fd) { | |||
128 | //must check end ...the timer might remove | 128 | //must check end ...the timer might remove |
129 | //it self from the list (should be fixed in the future) | 129 | //it self from the list (should be fixed in the future) |
130 | for(; it != m_timerlist.end(); ++it) { | 130 | for(; it != m_timerlist.end(); ++it) { |
131 | tm.tv_sec = (*it)->getStartTime().tv_sec + | 131 | //This is to make sure we don't get an invalid iterator |
132 | (*it)->getTimeout().tv_sec; | 132 | //when we do fireTimeout |
133 | tm.tv_usec = (*it)->getStartTime().tv_usec + | 133 | BTimer &t = *(*it); |
134 | (*it)->getTimeout().tv_usec; | 134 | tm.tv_sec = t.getStartTime().tv_sec + |
135 | t.getTimeout().tv_sec; | ||
136 | tm.tv_usec = t.getStartTime().tv_usec + | ||
137 | t.getTimeout().tv_usec; | ||
135 | 138 | ||
136 | if ((now.tv_sec < tm.tv_sec) || | 139 | if ((now.tv_sec < tm.tv_sec) || |
137 | (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) | 140 | (now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec)) |
138 | break; | 141 | break; |
139 | 142 | ||
140 | (*it)->fireTimeout(); | 143 | t.fireTimeout(); |
141 | |||
142 | // restart the current timer so that the start time is updated | 144 | // restart the current timer so that the start time is updated |
143 | if (! (*it)->doOnce()) | 145 | if (! t.doOnce()) |
144 | (*it)->start(); | 146 | t.start(); |
145 | else { | 147 | else { |
146 | (*it)->stop(); | 148 | t.stop(); |
147 | it--; | 149 | it--; |
148 | } | 150 | } |
149 | } | 151 | } |