Use a while loop instead of a for loop. Makes it easier to erase an element.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6243 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-02-25 12:42:28 +00:00
parent 51ad0ec92f
commit fa504a8603
2 changed files with 12 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2003-02-25 Angus Leeming <leeming@lyx.org>
* forkedcontr.C (timer): Use a while loop rather than for; makes it
easier to erase an element.
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* forkedcontr.C (timer): don't start a running timer.
@ -6,7 +11,6 @@
* filetools.C (PutEnv): removed (unused)
2003-02-17 John Levon <levon@movementarian.org>
* forkedcall.h:

View File

@ -83,8 +83,9 @@ void ForkedcallsController::timer()
{
ListType::size_type start_size = forkedCalls.size();
for (ListType::iterator it = forkedCalls.begin();
it != forkedCalls.end(); ++it) {
ListType::iterator it = forkedCalls.begin();
ListType::iterator end = forkedCalls.end();
while (it != end) {
ForkedProcess * actCall = *it;
pid_t pid = actCall->pid();
@ -133,12 +134,10 @@ void ForkedcallsController::timer()
// Emit signal and remove the item from the list
actCall->emitSignal();
delete actCall;
// erase returns the next iterator, so decrement it
// to continue the loop.
ListType::iterator prev = it;
--prev;
forkedCalls.erase(it);
it = prev;
// erase returns the next element in the list
it = forkedCalls.erase(it);
} else {
++it;
}
}