Change a few iterations over list to what is apparently a modification safe syntax, may fix issue #208 and #217 - needs testing of course.
authornemo
Mon, 11 Apr 2011 11:22:10 -0400
changeset 5140 932307228d05
parent 5139 090a8b8d1083
child 5141 2fb6555011d3
Change a few iterations over list to what is apparently a modification safe syntax, may fix issue #208 and #217 - needs testing of course.
QTfrontend/chatwidget.cpp
QTfrontend/game.cpp
QTfrontend/hwform.cpp
QTfrontend/teamselect.cpp
--- a/QTfrontend/chatwidget.cpp	Mon Apr 11 01:30:43 2011 +0200
+++ b/QTfrontend/chatwidget.cpp	Mon Apr 11 11:22:10 2011 -0400
@@ -409,10 +409,8 @@
 void HWChatWidget::nickRemoved(const QString& nick)
 {
     QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
-    for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) {
-        chatNicks->takeItem(chatNicks->row(*it));
-        ++it;
-    }
+    QListIterator<QListWidgetItem *> it(items);
+    while(it.hasNext()) chatNicks->takeItem(chatNicks->row(it.next()));
 
     lblCount->setText(QString::number(chatNicks->count()));
 }
--- a/QTfrontend/game.cpp	Mon Apr 11 01:30:43 2011 +0200
+++ b/QTfrontend/game.cpp	Mon Apr 11 11:22:10 2011 -0400
@@ -82,8 +82,8 @@
 
     if (m_pTeamSelWidget)
     {
-        QList<HWTeam> teams = m_pTeamSelWidget->getPlayingTeams();
-        for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it)
+        QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
+        while(it.hasNext())
         {
             HWProto::addStringToBuffer(buf, QString("eammloadt %1").arg(ammostr.mid(0, cAmmoNumber)));
             HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber)));
@@ -91,7 +91,8 @@
             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
             if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
             HWProto::addStringListToBuffer(buf,
-                (*it).TeamGameConfig(gamecfg->getInitHealth()));
+                it.next().TeamGameConfig(gamecfg->getInitHealth()));
+            ;
         }
     }
     RawSendIPC(buf);
@@ -389,9 +390,9 @@
     if (m_pTeamSelWidget)
     {
         QByteArray buf;
-        QList<HWTeam> teams = m_pTeamSelWidget->getPlayingTeams();
-        for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it)
-            HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg((*it).TeamName));
+        QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
+        while(it.hasNext())
+            HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(it.next().TeamName));
         RawSendIPC(buf);
     }
 }
--- a/QTfrontend/hwform.cpp	Mon Apr 11 01:30:43 2011 +0200
+++ b/QTfrontend/hwform.cpp	Mon Apr 11 11:22:10 2011 -0400
@@ -593,11 +593,10 @@
         curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget;
     }
 
-    QList<HWTeam> teams = curTeamSelWidget->getDontPlayingTeams();
     QStringList tmnames;
-    for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) {
-        tmnames += it->TeamName;
-    }
+    QListIterator<HWTeam> it(curTeamSelWidget->getDontPlayingTeams());
+    while(it.hasNext()) tmnames += it.next().TeamName;
+
     //UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring
     UpdateTeamsLists();
 
--- a/QTfrontend/teamselect.cpp	Mon Apr 11 01:30:43 2011 +0200
+++ b/QTfrontend/teamselect.cpp	Mon Apr 11 11:22:10 2011 -0400
@@ -243,7 +243,6 @@
 
 void TeamSelWidget::resetPlayingTeams(const QList<HWTeam>& teamslist)
 {
-  QList<HWTeam>::iterator it;
   //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) {
   //framePlaying->removeTeam(*it);
   //}
@@ -256,9 +255,8 @@
   frameDontPlaying->resetTeams();
   curDontPlayingTeams.clear();
 
-  for (QList<HWTeam>::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
-    addTeam(*it);
-  }
+  QListIterator<HWTeam> it(teamslist);
+  while(it.hasNext()) addTeam(it.next());
 }
 
 bool TeamSelWidget::isPlaying(HWTeam team) const