]> git.lyx.org Git - features.git/commitdiff
use std::list<int> for pidwaitlist
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 21 Jan 2000 18:33:54 +0000 (18:33 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 21 Jan 2000 18:33:54 +0000 (18:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@437 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/insets/figinset.C

index 692aea7a97f9874c3b8dd36d898654f90ff3687b..b1d5143ef41cbd25df2da7afc4333e89a41ab38b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2000-01-21  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
+       * src/insets/figinset.C: get rid of struct pidwaitpit, use a
+       std::list<int> instead.
+       (addpidwait): reflect move to std::list<int>
+       (sigchldchecker): ditto
+
        * src/bmtable.c (fl_set_bmtable_file): have arguments in the X r5
        version also. 
 
index 1e69c675ebf5868197ae057eedbe32256bb311bc..618ff085011f48d3c24be4b0daf05cfc8e23d846 100644 (file)
@@ -41,9 +41,13 @@ extern long int background_pixels;
 #include <cmath>
 #include <fstream>
 #include <queue>
+#include <list>
+#include <algorithm>
 using std::ofstream;
 using std::ifstream;
 using std::queue;
+using std::list;
+using std::find;
 
 #include "figinset.h"
 #include "lyx.h"
@@ -95,11 +99,6 @@ struct queue_element {
        figdata * data;        // we are doing it for this data
 };
 
-struct pidwait {
-       int pid;                /* pid to wait for */
-       pidwait * next; /* next */
-};
-
 static int const MAXGS = 3;                    /* maximum 3 gs's at a time */
 
 static Figref ** figures;      /* all the figures */
@@ -120,26 +119,22 @@ static int gs_spc;                        // shades per color
 static bool gs_gray;                   // is grayscale?
 static int gs_allcolors;               // number of all colors
 
-static pidwait * pw = 0;               // pid wait list
-
+static list<int> pidwaitlist; // pid wait list
 
 extern Colormap color_map;
 
 void addpidwait(int pid)
 {
        // adds pid to pid wait list
-       register pidwait * p = new pidwait;
-
-       p->pid = pid;
-       p->next = pw;
-       pw = p;
+       pidwaitlist.push_back(pid);
 
        if (lyxerr.debugging()) {
-               lyxerr << "Pids to wait for: " << p->pid << endl;
-               while (p->next) {
-                       p = p->next;
-                       lyxerr << p->pid << endl;
+               lyxerr << "Pids to wait for: \n";
+               for (list<int>::const_iterator cit = pidwaitlist.begin();
+                    cit != pidwaitlist.end(); ++cit) {
+                       lyxerr << (*cit) << '\n';
                }
+               lyxerr << flush;
        }
 }
 
@@ -198,15 +193,15 @@ extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
                                                << "Cannot fork, using slow "
                                                "method for pixmap translation." << endl;
                                        tmpdisp = fl_display;
-                               } else if (forkstat > 0) {
+                               } else if (forkstat > 0) { // parent
                                        // register child
                                        if (lyxerr.debugging()) {
                                                lyxerr << "Spawned child "
                                                       << forkstat << endl;
                                        }
                                        addpidwait(forkstat);
-                                       break; // in parent process
-                               } else {
+                                       break;
+                               } else {  // child
                                        tmpdisp = XOpenDisplay(XDisplayName(0));
                                        XFlush(tmpdisp);
                                }
@@ -887,23 +882,15 @@ void sigchldchecker(pid_t pid, int * status)
        }
        if (!pid_handled) {
                lyxerr.debug() << "Checking pid in pidwait" << endl;
-               pidwait * p = pw, * prev = 0;
-               while (p) {
-                       if (pid == p->pid) {
-                               lyxerr.debug() << "Found pid in pidwait" << endl;
-                               lyxerr.debug() << "Caught child pid of recompute routine " << pid << endl;
-                               if (prev)
-                                       prev->next = p->next;
-                               else
-                                       pw = p->next;
-                               delete p;
-                               break;
-                       }
-                       prev = p;
-                       p = p->next;
+               list<int>::iterator it = find(pidwaitlist.begin(),
+                                             pidwaitlist.end(), pid);
+               if (it != pidwaitlist.end()) {
+                       lyxerr.debug() << "Found pid in pidwait\n"
+                                      << "Caught child pid of recompute "
+                               "routine" << pid << endl;
+                       pidwaitlist.erase(it);
                }
        }
-
        if (pid == -1) {
                lyxerr.debug() << "waitpid error" << endl;
                switch (errno) {