Fix problems from porting Qt3->Qt4, which were caused by introducing takeFirst()...
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 24 Jan 2016 23:53:42 +0000 (00:53 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Sun, 24 Jan 2016 23:53:42 +0000 (00:53 +0100)
src/help/help.cpp
src/lgconfig/lgconfig.cpp
src/net/lognet.cpp
src/preproc/prep.cpp

index 714589266c167de22ab98d6b6e9a653731118c1e..9645f411e9559827b554d7e5020b70c330e72b80 100644 (file)
@@ -233,11 +233,12 @@ void HTMLAnalyzer::AnalyzeTag(QString *t)
 void HTMLAnalyzer::DumpList()
 {
        Tag *pom;
-       pom = tags.first();
-       while (pom != NULL) {
+       QListIterator<Tag *> tagsIterator(tags);
+
+       while (tagsIterator.hasNext()) {
+               pom = tagsIterator.next();
                fprintf(stderr, "%s:%s,%s,%s\n", names[pom->tag_type],
                        pom->tag_text, pom->tag_link, pom->tag_label);
-               pom=tags.takeFirst();
        }
 }
 
@@ -245,12 +246,13 @@ void HTMLAnalyzer::PackLinks()
 {
        Tag *pom,*pom1;
        char s[255];
+       QListIterator<Tag *> tagsIterator(tags);
 
-       pom = tags.first();
-       while (pom!=NULL) {
+       while (tagsIterator.hasNext()) {
+               pom = tagsIterator.next();
                if ((pom->tag_type == TAG_LINK) ||
                        (pom->tag_type == TAG_ANCHOR)) {
-                       pom1 = tags.takeFirst();
+                       pom1 = tagsIterator.next();
                        strcpy(s, "");
                        while ((pom1 != NULL) &&
                                (pom1->tag_type != TAG_LINK_END)) {
@@ -263,7 +265,7 @@ void HTMLAnalyzer::PackLinks()
                        tags.removeOne(pom1);
                        pom = tags.current();
                } else {
-                       pom = tags.takeFirst();
+                       pom = tagsIterator.next();
                }
        }
 }
@@ -272,14 +274,15 @@ void HTMLAnalyzer::PackLinks()
 Tag *HTMLAnalyzer::CheckTag(int x,int y)
 {
        Tag *pom;
-       pom=tags.first();
-       while (pom != NULL) {
+       QListIterator<Tag *> tagsIterator(tags);
+
+       while (tagsIterator.hasNext()) {
+               pom = tagsIterator.next();
                if (pom->tag_type==TAG_LINK)
                        if ((x >= pom->x) && (x <= pom->x + pom->w) &&
                                (y >= pom->y) && (y <= pom->y + pom->h)) {
                                return pom;
                        }
-               pom=tags.takeFirst();
        }
        return NULL;
 }
@@ -287,13 +290,14 @@ Tag *HTMLAnalyzer::CheckTag(int x,int y)
 Tag *HTMLAnalyzer::FindAnchor(char *name)
 {
        Tag *pom;
-       pom = tags.first();
-       while (pom != NULL) {
+       QListIterator<Tag *> tagsIterator(tags);
+
+       while (tagsIterator.hasNext()) {
+               pom = tagsIterator.next();
                if ((pom->tag_type == TAG_ANCHOR) &&
                        (strcmp(pom->tag_label, name) == 0)) {
                                return(pom);
                        }
-               pom=tags.takeFirst();
        }
        return pom;
 }
@@ -473,8 +477,10 @@ void QHTML::DrawList()
                map->fill(backgroundColor());
                p.begin(map);
 
-               pom = analyzer->tags.first();
-               while (pom != NULL) {
+               QListIterator<Tag *> tagsIterator(tags);
+
+               while (tagsIterator.hasNext()) {
+                       pom = tagsIterator.next();
                        switch(pom->tag_type) {
                        case TAG_TEXT:
                                p.setFont(*actual_font);
@@ -576,7 +582,6 @@ void QHTML::DrawList()
                                cy = cy + p.fontMetrics().height();
                                break;
                        }
-                       pom = analyzer->tags.takeFirst();
                }
                p.end();
                repaint();
index 2ef36eddd25110516cf910af07609691b98f880f..58872ca4c0d5e8f2fdec39e213acc758abb1263d 100644 (file)
@@ -86,12 +86,12 @@ QInstall::QInstall()
 bool QInstall::check_id(int id)
 {
        VLPEntry *pom;
+       QListIterator<VLPEntry *> nodesIterator(Nodes);
 
-       pom = Nodes.first();
-       while (pom != NULL) {
+       while (nodesIterator.hasNext()) {
+               pom = nodesIterator.next();
                if (pom->ID == id)
                        return FALSE;
-               pom = Nodes.takeFirst();
        }
        return TRUE;
 }
@@ -99,12 +99,12 @@ bool QInstall::check_id(int id)
 bool QInstall::check_addr(char *addr)
 {
        VLPEntry *pom;
+       QListIterator<VLPEntry *> nodesIterator(Nodes);
 
-       pom = Nodes.first();
-       while (pom != NULL) {
+       while (nodesIterator.hasNext()) {
+               pom = nodesIterator.next();
                if (strcmp(pom->addr, addr) == 0)
                        return FALSE;
-               pom = Nodes.takeFirst();
        }
        return TRUE;
 }
@@ -213,11 +213,13 @@ void QInstall::DelNode()
 
        if (nodelist->currentItem() >= 0) {
                strcpy(pom, nodelist->text(nodelist->currentItem()).toStdString().c_str());
-               vpom = Nodes.first();
-               while (vpom != NULL) {
+
+               QListIterator<VLPEntry *> nodesIterator(Nodes);
+               
+               while (nodesIterator.hasNext()) {
+                       vpom = nodesIterator.next();
                        if (strcmp(pom, vpom->item) == 0)
                                break;
-                       vpom = Nodes.takeFirst();
                }
                if (vpom != NULL)
                        if (QMessageBox::question(this, "Delete VLP", "Are you sure?", "Yes", "No")) {
@@ -268,8 +270,10 @@ void QInstall::SetOptions()
 
        if (dlg.exec()) {
                if (!Nodes.isEmpty()) {
-                       pom = Nodes.first();
-                       while (pom != NULL) {
+                       QListIterator<VLPEntry *> nodesIterator(Nodes);
+                       
+                       while (nodesIterator.hasNext()) {
+                               pom = nodesIterator.next();
                                j = Nodes.indexOf(pom);
                                sprintf(pomstr, "%s.cfg", pom->addr);
 
@@ -320,7 +324,6 @@ void QInstall::SetOptions()
                                config_destroy(&cfg);
 
                                pom = Nodes.at(j);
-                               pom = Nodes.takeFirst();
                        }
                }
        }
index 58e481380fc0e502142b6985a60bf1e5bb375e2c..4109c1dff066d38313819aa640d4ec132a9812f8 100644 (file)
@@ -377,16 +377,17 @@ void NETMOD::check_node(int n, int sc)
 
        m.msg_type = MSG_NET;
        m.param.pword[0] = NET_NODE_EXIST;
-
-       pomlink = Links.first();
        m.param.pword[1] = 0;
-       while (pomlink != NULL) {
+
+       QListIterator<NETlink*> linksIterator(Links);
+
+       while (linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                if (pomlink->node_number == n) {
                        m.param.pword[1] = 1;
                        strcpy(m.param.pstr, pomlink->addr);
                        break;
                }
-               pomlink = Links.takeFirst();
        }
        write(sc, &m, sizeof(MESSAGE));
 }
@@ -413,21 +414,22 @@ void NETMOD::get_internal()
        FD_SET(kernel_sock, &readset);
        nrset = kernel_sock;
 
-       pomlink = Interpreters.first();
-       while (pomlink != NULL) {
+       QListIterator<INTlink*> interpretersIterator(Interpreters);
+       while (interpretersIterator.hasNext()) {
+               pomlink = interpretersIterator.next();
                FD_SET(pomlink->sock, &readset);
                if (nrset < pomlink->sock) {
                        nrset = pomlink->sock;
                }
-               pomlink = Interpreters.takeFirst();
        }
 
        if (select(nrset + 1, &readset, &writeset, 0, (struct timeval *)&tout) >
                                                                        0) {
 
                /* Check request sockets */
-               pomlink = Interpreters.first();
-               while (pomlink != NULL) {
+               interpretersIterator.toFront();
+               while (interpretersIterator.hasNext()) {
+                       pomlink = interpretersIterator.next();
                        if (FD_ISSET(pomlink->sock, &readset)) {
                                nr = read(pomlink->sock, &msg, sizeof(MESSAGE));
                                if (nr > 0) {
@@ -451,7 +453,6 @@ void NETMOD::get_internal()
                                        }
                                }
                        } /* ISSET */
-                       pomlink=Interpreters.takeFirst();
                } // while
 
                /* Check internal socket */
@@ -645,24 +646,24 @@ void NETMOD::remote_messages()
        FD_ZERO(&wset);
        max = 0;
 
-       pomlink = Links.first();
-       while (pomlink != NULL) {
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                if (pomlink->connected) {
                        FD_SET(pomlink->sock, &rset);
                        if (max < pomlink->sock){
                                max = pomlink->sock;
                        }
                }
-               pomlink=Links.takeFirst();
        }
 
        if (select(max + 1, &rset, &wset, 0, (struct timeval *)&tout) > 0) {
-               pomlink=Links.first();
-               while (pomlink!=NULL) {
+               linksIterator.toFront();
+               while (linksIterator.hasNext()) {
+                       pomlink = linksIterator.next();
                        if (FD_ISSET(pomlink->sock,&rset)) {
                                get_message(pomlink);
                        }
-                       pomlink=Links.takeFirst();
                }
        }
 }
@@ -685,23 +686,25 @@ void NETMOD::doitall() {
        if (max < kernel_sock) {
                max=kernel_sock;
        }
-       pomlink2 = Interpreters.first();
-       while (pomlink2 != NULL) {
+
+       QListIterator<INTlink*> interpretersIterator(Interpreters);
+       while (interpretersIterator.hasNext()) {
+               pomlink2 = interpretersIterator.next();
                FD_SET(pomlink2->sock, &rset);
                if (max < pomlink2->sock) {
-                       max=pomlink2->sock;
+                       max = pomlink2->sock;
                }
-               pomlink2 = Interpreters.takeFirst();
        }
-       pomlink = Links.first();
-       while (pomlink != NULL) {
+
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                if (pomlink->connected) {
                        FD_SET(pomlink->sock, &rset);
                        if (max < pomlink->sock) {
                                max = pomlink->sock;
                        }
                }
-               pomlink=Links.takeFirst();
        }
 
        /* odczyt */
@@ -727,8 +730,9 @@ void NETMOD::doitall() {
 
                /* get internal message*/
                /* Check request sockets */
-               pomlink2 = Interpreters.first();
-               while (pomlink2 != NULL) {
+               interpretersIterator.toFront();
+               while (interpretersIterator.hasNext()) {
+                       pomlink2 = interpretersIterator.next();
                        if (FD_ISSET(pomlink2->sock,&rset)) {
                                nr = read(pomlink2->sock, &msg, sizeof(MESSAGE));
                                if (nr > 0) {
@@ -752,7 +756,6 @@ void NETMOD::doitall() {
                                        }
                                }
                        }/* ISSET */
-                       pomlink2 = Interpreters.takeFirst();
                }/* while */
 
                /* Check internal socket */
@@ -818,11 +821,11 @@ void NETMOD::doitall() {
 
                /* get remote message*/
 
-               pomlink=Links.first();
-               while (pomlink != NULL) {
+               linksIterator.toFront();
+               while (linksIterator.hasNext()) {
+                       pomlink = linksIterator.next();
                        if (FD_ISSET(pomlink->sock, &rset))
                                get_message(pomlink);
-                       pomlink=Links.takeFirst();
                }
        } // select 
 }
@@ -855,11 +858,11 @@ void NETMOD::connect_seq(char *a)
        struct sockaddr_in svr;
        int j, on;
 
-       pom = Links.first();
-       while (pom != NULL) {
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pom = linksIterator.next();
                if (strcmp(pom->addr, a) == 0)
                        return;
-               pom = Links.takeFirst();
        }
        pom = new NETlink;
        strcpy(pom->addr, a);
@@ -889,11 +892,12 @@ void NETMOD::check_links()
        int j = 1;
        struct sockaddr_in svr;
        NETlink *pomlink;
+       QListIterator<NETlink*> linksIterator(Links);
 
        /* connect to all other nodes */
        if (!all_connected) {
-               pomlink = Links.first();
-               while (pomlink != NULL) {
+               while (linksIterator.hasNext()) {
+                       pomlink = linksIterator.next();
                        if (!(pomlink->connected)) {
                                bzero(&svr, sizeof(svr));
                                svr.sin_family = AF_INET;
@@ -913,17 +917,16 @@ void NETMOD::check_links()
                                        sock_reopen(pomlink);
                                }
                        } /* not connected */
-                       pomlink = Links.takeFirst();
                } /* while */
        } /* if */
        all_connected = TRUE;
-       pomlink = Links.first();
-       while(pomlink != NULL) {
+       linksIterator.toFront();
+       while(linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                if (pomlink->connected == FALSE) {
                        all_connected = FALSE;
                        break;
                }
-               pomlink = Links.takeFirst();
        }
 }
 
@@ -977,10 +980,11 @@ void NETMOD::send_code_ack(NETlink *lnk)
 void NETMOD::send_to_all(MESSAGE *msg)
 {
        NETlink *pomlink;
-       pomlink = Links.first();
-       while (pomlink != NULL) {
+
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                write(pomlink->sock, msg, sizeof(MESSAGE));
-               pomlink = Links.takeFirst();
        }
 }
 
@@ -1004,10 +1008,11 @@ void NETMOD::exit_sequence()
        ::close(kernel_sock);
        ::close(listen_sock);
        unlink(kername);
-       pomlink = Links.first();
-       while (pomlink != NULL) {
+
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
                ::close(pomlink->sock);
-               pomlink = Links.takeFirst();
        }
        exit(0);
 }
@@ -1022,40 +1027,42 @@ void NETMOD::disconnect_seq()
        m.param.pword[0] = NET_DISCONNECT;
        m.param.pword[1] = MyNode;
 
-       p = Links.first();
-       while(p != NULL) {
+       QListIterator<NETlink*> linksIterator(Links);
+       while(linksIterator.hasNext()) {
+               p = linksIterator.next();
                send_to_node(p, &m);
-               p=Links.takeFirst();
        }
-       p = Links.first();
-       while(p != NULL) {
+
+       linksIterator.toFront();
+       while(linksIterator.hasNext()) {
+               p = linksIterator.next();
                ::close(p->sock);
-               p = Links.takeFirst();
        }
        Links.clear();
 }
 
 NETlink * NETMOD::findNETlink(int node)
 {
-       NETlink *pomlink;
-       pomlink = Links.first();
-       while(pomlink != NULL) {
+       NETlink *pomlink = NULL;
+       QListIterator<NETlink*> linksIterator(Links);
+
+       while(linksIterator.hasNext()) {
+               pomlink = linksIterator.next();
+
                if (pomlink->node_number == node)
                        return pomlink;
-
-               pomlink = Links.takeFirst();
-       } 
+       }
        return pomlink;
 }
 
 INTlink * NETMOD::findINTlink(int id)
 {
-       INTlink *pomlink;
-       pomlink = Interpreters.first();
-       while(pomlink != NULL) {
+       INTlink *pomlink = NULL;
+       QListIterator<INTlink*> interpretersIterator(Interpreters);
+       while(interpretersIterator.hasNext()) {
+               pomlink = interpretersIterator.next();
                if (pomlink->ID == id)
                        return pomlink;
-               pomlink = Interpreters.takeFirst();
        }
        return pomlink;
 }
@@ -1206,8 +1213,10 @@ void NETMOD::conn_info(int sk)
        m.msg_type = MSG_NET;
        m.param.pword[0] = NET_INFO;
        strcpy(m.param.pstr, "");
-       pom = Links.first();
-       while (pom != NULL) {
+
+       QListIterator<NETlink*> linksIterator(Links);
+       while (linksIterator.hasNext()) {
+               pom = linksIterator.next();
                sprintf(poms, "%d=%s;", pom->node_number, pom->addr);
                strcat(m.param.pstr, poms);
                k++;
@@ -1216,7 +1225,6 @@ void NETMOD::conn_info(int sk)
                        write(sk, &m, sizeof(MESSAGE));
                        k = 0;
                }
-               pom = Links.takeFirst();
        }
        if (k > 0) {
                m.param.pword[1] = k;
index dda3901c4149ad32f404b8ce82848306d95db08e..00b564edd523de2ea95e80c86b2f1adf17134635 100644 (file)
@@ -31,41 +31,42 @@ IncFile *findTrueLine(int ln, int *trueline)
        int c1 = 0;
 //     int c2 = 0;
 
-       if (inc.isEmpty()) {
+       QListIterator<NETlink*> incFileIterator(inc);
+       if (!incFileIterator.hasNext()) {
                *trueline = ln;
                return NULL;
-       } 
+       }
        pl.clear();
-       pom = inc.first();
+       pom = incFileIterator.next();
        if (pom->start > ln) {
                *trueline = ln;
                return NULL;
        }
 
-       while ((pom != NULL) && (ln > pom->start)) {
+       while ((incFileIterator.hasNext()) && (ln > pom->start)) {
                if (ln < pom->start + pom->len) {
                        *trueline = ln-pom->start;
                        return pom;
                }
                pl.append(pom);
-               pom=inc.takeFirst();
+               pom=incFileIterator.next();
        }
 
-       if (pom != NULL) {
-               pom1 = pl.first();
+       if (incFileIterator.hasNext()) {
+               QListIterator<NETlink*> plIterator(pl);
                c1=0;
-               while (pom1 != NULL) {
+               while (plIterator.hasNext()) {
+                       pom1 = plIterator.next();
                        c1 += pom1->len;
-                       pom1 = pl.takeFirst();
                }
                *trueline = ln - c1;
                return NULL;
        } else {
-               pom1 = inc.first();
+               incFileIterator.toFront();
                c1 = 0;
-               while (pom1 != NULL) {
+               while (incFileIterator.hasNext()) {
+                       pom1 = incFileIterator.next();
                        c1 += pom1->len;
-                       pom1=inc.takeFirst();
                }
                *trueline = ln - c1;
                return NULL;