]> Dogcows Code - chaz/tint2/commitdiff
fixed memory leak
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 18 Nov 2008 22:14:01 +0000 (22:14 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 18 Nov 2008 22:14:01 +0000 (22:14 +0000)
src/Makefile
src/config.c
src/taskbar/task.c
src/taskbar/taskbar.c
src/tint.c
src/tint2

index 31fe027cd57b81b7a4f808b30300ac83d0351adc..5b8b2b77b76b767ec6d2faf88e98b4190065a8ef 100644 (file)
@@ -22,7 +22,7 @@ endif
 
 $(PROGNAME): $(FILES) $(SYSTRAYOBJ)
        $(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS)
-       strip $(PROGNAME)
+       #strip $(PROGNAME)
 
 install:
        mkdir -p $(BINDIR)
index 850fbc9e99cbb7ee20d7abb81ec89b4918eca8e3..e4b6c2d5777e812d75a748242fd25595dbf07ef2 100644 (file)
 
 void cleanup_taskbar() 
 {   
-   free_area(&panel.area);
-
+   GSList *l0;
+   Task *tsk;
+   
    int i, nb;
-   Task *tsk, *next;
-
    nb = panel.nb_desktop * panel.nb_monitor;
    for (i=0 ; i < nb ; i++) {
-/* TODO: voir ce code !!
-      for (tsk = panel.taskbar[i].tasklist; tsk ; tsk = next) {
-         next = tsk->next;
+      l0 = panel.taskbar[i].area.list;
+      while (l0) {
+         tsk = l0->data;
+         l0 = l0->next;
+         // careful : remove_task change l0->next
          remove_task (tsk);
       }
-*/
+      
+      free_area (&panel.taskbar[i].area);
    }
 
    free(panel.taskbar);
    panel.taskbar = 0;
+   
+   free_area(&panel.area);
 }
 
 
index 4115cbe6d84baaa2f52370e8278be111a8ef16ef..960b53bfd85cd9fad1b5348eb610febbb38d7eb3 100644 (file)
@@ -65,14 +65,15 @@ void add_task (Window win)
          new_tsk->title = 0;
       }
       if (new_tsk->icon_data) {
-         XFree (new_tsk->icon_data);
+         free (new_tsk->icon_data);
          new_tsk->icon_data = 0;
       }
       free(new_tsk);
       fprintf(stderr, "task on all desktop : ignored\n");
       return;
    }
-   
+      
+   //printf("add_task %d  %s\n", index(desktop, monitor), new_tsk->title);
    Taskbar *tskbar;
    tskbar = &panel.taskbar[index(desktop, monitor)];     
    new_tsk->area.parent = tskbar;
@@ -92,13 +93,14 @@ void remove_task (Task *tsk)
    tskbar->area.list = g_slist_remove(tskbar->area.list, tsk);
    resize_tasks (tskbar);
    redraw (&tskbar->area);
+   //printf("remove_task %d  %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
 
    if (tsk->title) {
       free (tsk->title);
       tsk->title = 0;
    }
    if (tsk->icon_data) {
-      XFree (tsk->icon_data);
+      free (tsk->icon_data);
       tsk->icon_data = 0;
    }
    XFreePixmap (server.dsp, tsk->area.pmap);
index db08f6da2cfdae821058445326fbe847a3729f5c..99e6a17f857248a3e8bf47471619850f62486340 100644 (file)
@@ -66,14 +66,17 @@ void task_refresh_tasklist ()
 
    nb = panel.nb_desktop * panel.nb_monitor;
    for (i=0 ; i < nb ; i++) {
-      for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) {
+      l0 = panel.taskbar[i].area.list;
+      while (l0) {
          tsk = l0->data;
-         
+         l0 = l0->next;
+
          if (tsk->win == active_win) panel.task_active = tsk;
          
          for (j = 0; j < num_results; j++) {
             if (tsk->win == win[j]) break;
          }
+         // careful : remove_task change l0->next
          if (tsk->win != win[j]) remove_task (tsk);
       }
    }
index 46c0c22dd46bd00d79e905ff99d87aa8c36b6095..821048bb426fcdd570418e08887f67e920c60cbd 100644 (file)
@@ -288,9 +288,11 @@ void event_property_notify (Window win, Atom at)
       }
       /* Window icon changed */
       else if (at == server.atom._NET_WM_ICON) {
-         if (tsk->icon_data != 0) XFree (tsk->icon_data);
+         if (tsk->icon_data) {
+            free (tsk->icon_data);
+            tsk->icon_data = 0;
+         }
          tsk->area.redraw = 1;
-         tsk->icon_data = 0;
          panel.refresh = 1;
       }
       /* Window desktop changed */
index 04154da944639c0a0d98abb6472f7252aa117b84..2eafd709b40ae3f9b19843e9e603affe5873fa8f 100755 (executable)
Binary files a/src/tint2 and b/src/tint2 differ
This page took 0.026053 seconds and 4 git commands to generate.