]> Dogcows Code - chaz/tint2/commitdiff
*fix* memleak
authorAndreas Fink <andreas.fink85@googlemail.com>
Tue, 5 Jan 2010 11:21:18 +0000 (11:21 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Tue, 5 Jan 2010 11:21:18 +0000 (11:21 +0000)
*fix* issue 192

src/config.c
src/systray/systraybar.c
src/util/area.c

index d5f7ef1a8776e58ae670c7b4a08f32ec03b92e3e..69ceda0bac8116977cb97eae666b6bfb010e52b6 100644 (file)
@@ -66,6 +66,7 @@ static int old_config_file;
 
 // temporary list of background
 static GSList *list_back;
+static int back_count;
 
 
 
@@ -73,6 +74,7 @@ void init_config()
 {
        // append full transparency background
        list_back = g_slist_append(0, calloc(1, sizeof(Area)));
+       back_count = 1;
 
        // tint2 could reload config, so we cleanup objects
        cleanup_systray();
@@ -192,6 +194,7 @@ void add_entry (char *key, char *value)
                Area *a = calloc(1, sizeof(Area));
                a->pix.border.rounded = atoi (value);
                list_back = g_slist_append(list_back, a);
+               back_count++;
        }
        else if (strcmp (key, "border_width") == 0) {
                Area *a = g_slist_last(list_back)->data;
@@ -284,6 +287,7 @@ void add_entry (char *key, char *value)
                panel_config.g_task.font_shadow = atoi (value);
        else if (strcmp (key, "panel_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.area.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.area.pix.border, &a->pix.border, sizeof(Border));
@@ -357,6 +361,7 @@ void add_entry (char *key, char *value)
        else if (strcmp (key, "battery_background_id") == 0) {
 #ifdef ENABLE_BATTERY
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.battery.area.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.battery.area.pix.border, &a->pix.border, sizeof(Border));
@@ -402,6 +407,7 @@ void add_entry (char *key, char *value)
        }
        else if (strcmp (key, "clock_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.clock.area.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.clock.area.pix.border, &a->pix.border, sizeof(Border));
@@ -436,12 +442,14 @@ void add_entry (char *key, char *value)
        }
        else if (strcmp (key, "taskbar_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.g_taskbar.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.g_taskbar.pix.border, &a->pix.border, sizeof(Border));
        }
        else if (strcmp (key, "taskbar_active_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.g_taskbar.pix_active.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.g_taskbar.pix_active.border, &a->pix.border, sizeof(Border));
@@ -502,12 +510,14 @@ void add_entry (char *key, char *value)
        }
        else if (strcmp (key, "task_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.g_task.area.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.g_task.area.pix.border, &a->pix.border, sizeof(Border));
        }
        else if (strcmp (key, "task_active_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&panel_config.g_task.area.pix_active.back, &a->pix.back, sizeof(Color));
                memcpy(&panel_config.g_task.area.pix_active.border, &a->pix.border, sizeof(Border));
@@ -529,6 +539,7 @@ void add_entry (char *key, char *value)
        }
        else if (strcmp (key, "systray_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color));
                memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border));
@@ -571,6 +582,7 @@ void add_entry (char *key, char *value)
        }
        else if (strcmp (key, "tooltip_background_id") == 0) {
                int id = atoi (value);
+               id = id < back_count ? id : 0;
                Area *a = g_slist_nth_data(list_back, id);
                memcpy(&g_tooltip.background_color, &a->pix.back, sizeof(Color));
                memcpy(&g_tooltip.border, &a->pix.border, sizeof(Border));
index dbe2c82e266ea493e565ae0b68c9cc5ec2cb4a38..f551623a660ffafaf615cebe6cb4c78bd18b168f 100644 (file)
@@ -516,7 +516,7 @@ void systray_render_icons(TrayWindow* traywin)
                render_image(panel->main_win, traywin->x, traywin->y, traywin->width, traywin->height);
                render_image(systray.area.pix.pmap, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height);
        }
-       imlib_free_image();
+       imlib_free_image_and_decache();
 }
 
 
index 3fb11168855297bd06c086bd87fac00b51d1a85c..acce72550f109e8a847b539aca23f7521fe2ab34 100644 (file)
@@ -256,4 +256,5 @@ void clear_pixmap(Pixmap p, int x, int y, int w, int h)
        Picture pict = XRenderCreatePicture(server.dsp, p, XRenderFindVisualFormat(server.dsp, server.visual), 0, 0);
        XRenderColor col = { .red=0, .green=0, .blue=0, .alpha=0 };
        XRenderFillRectangle(server.dsp, PictOpSrc, pict, &col, x, y, w, h);
+       XRenderFreePicture(server.dsp, pict);
 }
This page took 0.02827 seconds and 4 git commands to generate.