diff options
author | akir <akir> | 2004-11-01 02:43:07 (GMT) |
---|---|---|
committer | akir <akir> | 2004-11-01 02:43:07 (GMT) |
commit | fa5202c1202cda17a956f83221c9ef9ed72cbfd2 (patch) | |
tree | 1bad200248bf0302b6d496495ad8839c28f249ad /src/FbTk/Timer.cc | |
parent | fa1692180e18f95c9e8f46d37c5bb8797eeebd5a (diff) | |
download | fluxbox-fa5202c1202cda17a956f83221c9ef9ed72cbfd2.zip fluxbox-fa5202c1202cda17a956f83221c9ef9ed72cbfd2.tar.bz2 |
accepted patch #1057446, improved iterator in timer-code
Diffstat (limited to 'src/FbTk/Timer.cc')
-rw-r--r-- | src/FbTk/Timer.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index 335d247..78a861f 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc | |||
@@ -163,7 +163,7 @@ void Timer::updateTimers(int fd) { | |||
163 | 163 | ||
164 | //must check end ...the timer might remove | 164 | //must check end ...the timer might remove |
165 | //it self from the list (should be fixed in the future) | 165 | //it self from the list (should be fixed in the future) |
166 | for(it = m_timerlist.begin(); it != m_timerlist.end(); ++it) { | 166 | for(it = m_timerlist.begin(); it != m_timerlist.end(); ) { |
167 | //This is to make sure we don't get an invalid iterator | 167 | //This is to make sure we don't get an invalid iterator |
168 | //when we do fireTimeout | 168 | //when we do fireTimeout |
169 | Timer &t = *(*it); | 169 | Timer &t = *(*it); |
@@ -178,12 +178,21 @@ void Timer::updateTimers(int fd) { | |||
178 | 178 | ||
179 | t.fireTimeout(); | 179 | t.fireTimeout(); |
180 | // restart the current timer so that the start time is updated | 180 | // restart the current timer so that the start time is updated |
181 | if (! t.doOnce()) | 181 | if (! t.doOnce()) { |
182 | t.start(); | 182 | t.start(); |
183 | else { | 183 | |
184 | t.stop(); | 184 | // Note that this mustn't be done if we're deleting the |
185 | it--; | 185 | // entry from the list, so therefore it's not in the update |
186 | } | 186 | // section of the for loop |
187 | it++; | ||
188 | } else { | ||
189 | // Since the default stop behaviour results in the timer | ||
190 | // being removed, we must remove it here, so that the iterator | ||
191 | // lives well. Another option would be to add it to another | ||
192 | // list, and then just go through that list and stop them all. | ||
193 | it = m_timerlist.erase(it); | ||
194 | t.stop(); | ||
195 | } | ||
187 | } | 196 | } |
188 | 197 | ||
189 | last_time = time(0); | 198 | last_time = time(0); |