]> git.lyx.org Git - lyx.git/blobdiff - src/support/forkedcontr.C
split LyXText::rowlist_ into individual Paragraph::rows_ chunks
[lyx.git] / src / support / forkedcontr.C
index 40ec73d34e5d3a717405f1fac3d2b8b907af5304..c11daa5669c24d82cee2ab9d88c22f8ef7f596d9 100644 (file)
@@ -36,6 +36,9 @@ using std::find_if;
 using std::strerror;
 #endif
 
+namespace lyx {
+namespace support {
+
 // Ensure, that only one controller exists inside process
 ForkedcallsController & ForkedcallsController::get()
 {
@@ -83,8 +86,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();
@@ -102,7 +106,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.
@@ -130,19 +133,21 @@ 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;
                }
        }
 
-       if (!forkedCalls.empty()) {
+       if (!forkedCalls.empty() && !timeout_->running()) {
                timeout_->start();
        }
 
@@ -204,3 +209,6 @@ void ForkedcallsController::kill(pid_t pid, int tolerance)
                timeout_->stop();
        }
 }
+
+} // namespace support
+} // namespace lyx