summaryrefslogtreecommitdiff
path: root/pcr-testing/wbar/remove_static_iterator.patch
blob: 574c6775bf97cdf580fb9eb82ec751a29363248a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
diff --git a/src/core/Main.cc b/src/core/Main.cc
index c170e63..b6fa5f1 100644
--- a/src/core/Main.cc
+++ b/src/core/Main.cc
@@ -18,7 +18,6 @@
 static size_t configitems;
 static unsigned int taskbar;
 static std::list<App *> list;
-static std::list<App *>::iterator it;
 static App *p;
 
 static Bar *barra;
@@ -69,8 +68,7 @@ int main(int argc, char **argv)
 
         if (list.size() != 0)
         {
-            it = list.begin();
-            p = (*it);
+            p = *list.begin();
         }
         else
         {
@@ -440,7 +438,6 @@ int mapIcons()
     {
 	list.pop_back();
 	((SuperBar *)barra)->removeIcon();
-	it--;
     }
     // add currently running tasks to the list
     if ( (taskbar) && 
@@ -481,15 +478,17 @@ int mapIcons()
 	    }
 	}
     }
-    //if this is not an initial run
-    if (!firstrun)
-        // and we added no windows
-	if ((size_t)list.size() == configitems)
-	    //then there is no need to add icons
+
+    // if this is not an initial run and we added no windows
+    // then there is no need to add icons
+    if (!firstrun && (size_t)list.size() == configitems)
 	    return 0;
-    for (it++; it != list.end(); it++)
+
+    std::list<App *>::iterator appsIt = list.begin();
+    while ((size_t)std::distance(list.begin(), ++appsIt) < configitems);
+    while (++appsIt != list.end())
     {
-        p = (*it);
+        p = *appsIt;
         try
             {
         	if (p->getIconName() != "")
@@ -518,8 +517,7 @@ int mapIcons()
         }
 	(void) XSetErrorHandler(oldXHandler);
 	barra->scale();
-	if (firstrun)
-	    it--;
+
 	return 0;
 }