fixed memory leak

git-svn-id: http://tint2.googlecode.com/svn/trunk@21 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2008-11-18 22:14:01 +00:00
parent d29f3771de
commit 89bcccb468
6 changed files with 27 additions and 16 deletions

View file

@ -22,7 +22,7 @@ endif
$(PROGNAME): $(FILES) $(SYSTRAYOBJ) $(PROGNAME): $(FILES) $(SYSTRAYOBJ)
$(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS) $(CC) $(CFLAGS) -I. -Iutil -Iclock -Itaskbar -Isystray -o $(PROGNAME) $(FILES) $(FLAGS)
strip $(PROGNAME) #strip $(PROGNAME)
install: install:
mkdir -p $(BINDIR) mkdir -p $(BINDIR)

View file

@ -46,23 +46,27 @@
void cleanup_taskbar() void cleanup_taskbar()
{ {
free_area(&panel.area); GSList *l0;
Task *tsk;
int i, nb; int i, nb;
Task *tsk, *next;
nb = panel.nb_desktop * panel.nb_monitor; nb = panel.nb_desktop * panel.nb_monitor;
for (i=0 ; i < nb ; i++) { for (i=0 ; i < nb ; i++) {
/* TODO: voir ce code !! l0 = panel.taskbar[i].area.list;
for (tsk = panel.taskbar[i].tasklist; tsk ; tsk = next) { while (l0) {
next = tsk->next; tsk = l0->data;
l0 = l0->next;
// careful : remove_task change l0->next
remove_task (tsk); remove_task (tsk);
} }
*/
free_area (&panel.taskbar[i].area);
} }
free(panel.taskbar); free(panel.taskbar);
panel.taskbar = 0; panel.taskbar = 0;
free_area(&panel.area);
} }

View file

@ -65,7 +65,7 @@ void add_task (Window win)
new_tsk->title = 0; new_tsk->title = 0;
} }
if (new_tsk->icon_data) { if (new_tsk->icon_data) {
XFree (new_tsk->icon_data); free (new_tsk->icon_data);
new_tsk->icon_data = 0; new_tsk->icon_data = 0;
} }
free(new_tsk); free(new_tsk);
@ -73,6 +73,7 @@ void add_task (Window win)
return; return;
} }
//printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title);
Taskbar *tskbar; Taskbar *tskbar;
tskbar = &panel.taskbar[index(desktop, monitor)]; tskbar = &panel.taskbar[index(desktop, monitor)];
new_tsk->area.parent = tskbar; new_tsk->area.parent = tskbar;
@ -92,13 +93,14 @@ void remove_task (Task *tsk)
tskbar->area.list = g_slist_remove(tskbar->area.list, tsk); tskbar->area.list = g_slist_remove(tskbar->area.list, tsk);
resize_tasks (tskbar); resize_tasks (tskbar);
redraw (&tskbar->area); redraw (&tskbar->area);
//printf("remove_task %d %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title);
if (tsk->title) { if (tsk->title) {
free (tsk->title); free (tsk->title);
tsk->title = 0; tsk->title = 0;
} }
if (tsk->icon_data) { if (tsk->icon_data) {
XFree (tsk->icon_data); free (tsk->icon_data);
tsk->icon_data = 0; tsk->icon_data = 0;
} }
XFreePixmap (server.dsp, tsk->area.pmap); XFreePixmap (server.dsp, tsk->area.pmap);

View file

@ -66,14 +66,17 @@ void task_refresh_tasklist ()
nb = panel.nb_desktop * panel.nb_monitor; nb = panel.nb_desktop * panel.nb_monitor;
for (i=0 ; i < nb ; i++) { 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; tsk = l0->data;
l0 = l0->next;
if (tsk->win == active_win) panel.task_active = tsk; if (tsk->win == active_win) panel.task_active = tsk;
for (j = 0; j < num_results; j++) { for (j = 0; j < num_results; j++) {
if (tsk->win == win[j]) break; if (tsk->win == win[j]) break;
} }
// careful : remove_task change l0->next
if (tsk->win != win[j]) remove_task (tsk); if (tsk->win != win[j]) remove_task (tsk);
} }
} }

View file

@ -288,9 +288,11 @@ void event_property_notify (Window win, Atom at)
} }
/* Window icon changed */ /* Window icon changed */
else if (at == server.atom._NET_WM_ICON) { else if (at == server.atom._NET_WM_ICON) {
if (tsk->icon_data != 0) XFree (tsk->icon_data); if (tsk->icon_data) {
tsk->area.redraw = 1; free (tsk->icon_data);
tsk->icon_data = 0; tsk->icon_data = 0;
}
tsk->area.redraw = 1;
panel.refresh = 1; panel.refresh = 1;
} }
/* Window desktop changed */ /* Window desktop changed */

BIN
src/tint2

Binary file not shown.