[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r2314: Workaround the Qt 4.3.3 crashiness by avoiding indexOfTopLev (in vidalia/trunk: . src/vidalia/network)



Author: edmanm
Date: 2008-01-21 18:37:58 -0500 (Mon, 21 Jan 2008)
New Revision: 2314

Modified:
   vidalia/trunk/
   vidalia/trunk/src/vidalia/network/routerlistwidget.cpp
Log:
 r63@lysithea:  edmanm | 2008-01-21 18:37:51 -0500
 Workaround the Qt 4.3.3 crashiness by avoiding indexOfTopLevelItem().



Property changes on: vidalia/trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r63] on 90112fd6-a33b-4cea-8d39-48ff1d78625c

Modified: vidalia/trunk/src/vidalia/network/routerlistwidget.cpp
===================================================================
--- vidalia/trunk/src/vidalia/network/routerlistwidget.cpp	2008-01-21 18:42:03 UTC (rev 2313)
+++ vidalia/trunk/src/vidalia/network/routerlistwidget.cpp	2008-01-21 23:37:58 UTC (rev 2314)
@@ -149,8 +149,7 @@
 RouterListItem*
 RouterListWidget::findRouterByName(QString name)
 {
-  QList<QTreeWidgetItem *> list = findItems(name,
-                                            Qt::MatchExactly,
+  QList<QTreeWidgetItem *> list = findItems(name, Qt::MatchExactly,
                                             NameColumn);
   /* It's possible that more than one router could have the same name, but
    * without a fingerprint on which to match, we just have to pick one. We'll
@@ -166,29 +165,25 @@
 RouterListWidget::addRouter(RouterDescriptor rd)
 {
   QString id = rd.id();
-  if (!id.isEmpty()) {
-    RouterListItem *item = findRouterById(id);
-    if (item) {
-      /* This is an updated descriptor, so remove the old item and we'll 
-       * add a new, updated item. */
-      if (item->descriptor().online())
-        _onlineRouterCount--;
-      delete takeTopLevelItem(indexOfTopLevelItem(item));
-      _idmap.remove(id);
-    }
+  if (id.isEmpty())
+    return;
 
-    /* Add the router item to the list and store its descriptor. */
+  RouterListItem *item = findRouterById(id);
+  if (item) {
+    if (item->descriptor().online())
+      _onlineRouterCount--;
+    item->update(rd);
+  } else {
     item = new RouterListItem(this, rd);
     addTopLevelItem(item);
     _idmap.insert(id, item);
-
-    /* Set our status tip to the number of servers in the list */
-    if (rd.online())
-      _onlineRouterCount++;
-    setStatusTip(tr("%1 relays online (%2 total)")
-                              .arg(_onlineRouterCount)
-                              .arg(topLevelItemCount()));
   }
+
+  /* Set our status tip to the number of servers in the list */
+  if (rd.online())
+    _onlineRouterCount++;
+  setStatusTip(tr("%1 relays online (%2 total)").arg(_onlineRouterCount)
+                                                .arg(topLevelItemCount()));
 }
 
 /** Called when the selected items have changed. This emits the