Jean-Marc Lasgouttes wrote:

> Could you try to provide a fix for 1.3.x?
> 
> JMarc

Here it is.
        Alfredo
Index: forkedcontr.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/support/forkedcontr.C,v
retrieving revision 1.6.2.1
diff -u -p -u -r1.6.2.1 forkedcontr.C
--- forkedcontr.C	2003/02/25 16:53:24	1.6.2.1
+++ forkedcontr.C	2003/03/06 16:23:58
@@ -87,8 +87,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();
@@ -106,7 +107,6 @@ void ForkedcallsController::timer()
 
 		} else if (waitrpid == 0) {
 			// Still running. Move on to the next child.
-			continue;
 
 		} else if (WIFEXITED(stat_loc)) {
 			// Ok, the return value goes into retval.
@@ -134,15 +134,17 @@ void ForkedcallsController::timer()
 		}
 
 		if (remove_it) {
-			// Emit signal and remove the item from the list
+			forkedCalls.erase(it);
+
 			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;
+
+			/* start all over: emiting the signal can result
+			 * in changing the list (Ab)
+			 */
+			it = forkedCalls.begin();
+		} else {
+			++it;
 		}
 	}
 
Index: ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.149.2.2
diff -u -p -u -r1.149.2.2 ChangeLog
--- ChangeLog	2003/02/28 15:52:31	1.149.2.2
+++ ChangeLog	2003/03/06 16:24:00
@@ -1,3 +1,8 @@
+2003-03-06  Alfredo Braunstein <[EMAIL PROTECTED]>
+
+	* forkedcontr.C (timer): reworked the loop to allow running changes 
+	on the list.
+	
 2003-02-27  Ling Li  <[EMAIL PROTECTED]>
 
 	* lyxalgo.h (eliminate_duplicates): re-written to avoid the initial

Reply via email to