[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/utils/filelight/src/part/radialMap
From:       Andrew Coles <andrew_coles () yahoo ! co ! uk>
Date:       2009-04-07 0:00:38
Message-ID: 1239062438.124599.1320.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 950381 by coles:

Now doesn't crash when I wave the mouse around to create close-together labels - \
iterators were being incremented past  the end of the list of labels.



 M  +16 -8     labels.cpp  


--- trunk/playground/utils/filelight/src/part/radialMap/labels.cpp #950380:950381
@@ -139,24 +139,32 @@
     //   if so, remove the least significant labels
 
     QList<Label*>::iterator it = list.begin();
-    QList<Label*>::iterator jt = list.begin();
+    QList<Label*>::iterator jt = it;
 
-    for (jt = list.begin(); jt != list.end(); ++jt) //**** no need to check _it_ as \
jt will be NULL if _it_ was too +    const QList<Label*>::iterator jtEnd = \
list.end(); +
+    if (jt != jtEnd) ++jt;
+
+    while (jt != jtEnd)
     {
         //this method is fairly efficient
 
         if ((*it)->tooClose((*jt)->a)) {
             if ((*it)->lvl > (*jt)->lvl) {
+                const QList<Label*>::iterator jtDel = jt++;
+                list.erase(jtDel);
+            }
+            else
+            {
                 list.erase(it);
-                it = jt;
+                it = jt++;
             }
-            else
-                list.erase(jt);
         }
         else
-            ++it;
-
-        jt = it;
+        {
+            it = jt;
+            ++jt;
+        }
     }
 
     //used in next two steps


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic