]> Dogcows Code - chaz/tint2/commitdiff
cleanup default value on SIGUSR1
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Fri, 16 Apr 2010 18:50:03 +0000 (18:50 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Fri, 16 Apr 2010 18:50:03 +0000 (18:50 +0000)
src/battery/battery.c
src/battery/battery.h
src/clock/clock.c
src/clock/clock.h
src/config.c
src/systray/systraybar.c
src/systray/systraybar.h
src/taskbar/taskbar.c
src/taskbar/taskbar.h

index fd2ffce4bf59d74e6de728bad2e64bd638dcce59..9124e1648ac148a0177d1a8ce7515253d7f857e1 100644 (file)
@@ -37,15 +37,15 @@ PangoFontDescription *bat1_font_desc=0;
 PangoFontDescription *bat2_font_desc=0;
 struct batstate battery_state;
 int battery_enabled;
-int percentage_hide = 101;
+int percentage_hide;
 static timeout* battery_timeout=0;
 
 static char buf_bat_percentage[10];
 static char buf_bat_time[20];
 
 int8_t battery_low_status;
+unsigned char battery_low_cmd_send;
 char *battery_low_cmd=0;
-unsigned char battery_low_cmd_send=0;
 char *path_energy_now=0;
 char *path_energy_full=0;
 char *path_current_now=0;
@@ -159,23 +159,37 @@ void init_battery()
 void cleanup_battery()
 {
        battery_enabled = 0;
-       if (bat1_font_desc)
+       percentage_hide = 101;
+       battery_low_cmd_send = 0;
+
+       if (bat1_font_desc) {
                pango_font_description_free(bat1_font_desc);
-       if (bat2_font_desc)
+               bat1_font_desc = 0;
+       }
+       if (bat2_font_desc) {
                pango_font_description_free(bat2_font_desc);
-       if (path_energy_now)
+               bat2_font_desc = 0;
+       }
+       if (path_energy_now) {
                g_free(path_energy_now);
-       if (path_energy_full)
+               path_energy_now = 0;
+       }
+       if (path_energy_full) {
                g_free(path_energy_full);
-       if (path_current_now)
+               path_energy_full = 0;
+       }
+       if (path_current_now) {
                g_free(path_current_now);
-       if (path_status)
+               path_current_now = 0;
+       }
+       if (path_status) {
                g_free(path_status);
-       if (battery_low_cmd)
+               path_status = 0;
+       }
+       if (battery_low_cmd) {
                g_free(battery_low_cmd);
-
-       battery_low_cmd = path_energy_now = path_energy_full = path_current_now = path_status = 0;
-       bat1_font_desc = bat2_font_desc = 0;
+               battery_low_cmd = 0;
+       }
 }
 
 
index 39f9b11d30f877eaeaa55164c3d274f268489102..2e99abdc9545a2b89d26ecff0c58c79e5e72f5f0 100644 (file)
@@ -63,6 +63,8 @@ void update_battery();
 
 void init_battery();
 void init_battery_panel(void *panel);
+
+// freed memory and set default values
 void cleanup_battery();
 
 void draw_battery(void *obj, cairo_t *c);
index e29c138a687cf82825a38d24c2321ce669aebe83..d020c5269fb33109494cd6a412d311d3fe238720 100644 (file)
@@ -163,22 +163,46 @@ void init_clock_panel(void *p)
 void cleanup_clock()
 {
        clock_enabled = 0;
-       if (time1_font_desc)
+       if (time1_font_desc) {
                pango_font_description_free(time1_font_desc);
-       if (time2_font_desc)
+               time1_font_desc = 0;
+       }
+       if (time2_font_desc) {
                pango_font_description_free(time2_font_desc);
-       g_free(time1_format);
-       g_free(time2_format);
-       g_free(time_tooltip_format);
-       g_free(time1_timezone);
-       g_free(time2_timezone);
-       g_free(time_tooltip_timezone);
-       g_free(clock_lclick_command);
-       g_free(clock_rclick_command);
-       time1_font_desc = time2_font_desc = 0;
-       time1_format = time2_format = time_tooltip_format = 0;
-       time1_timezone = time2_timezone = time_tooltip_timezone = 0;
-       clock_lclick_command = clock_rclick_command = 0;
+               time2_font_desc = 0;
+       }
+       if (time1_format) {
+               g_free(time1_format);
+               time1_format = 0;
+       }
+       if (time2_format) {
+               g_free(time2_format);
+               time2_format = 0;
+       }
+       if (time_tooltip_format) {
+               g_free(time_tooltip_format);
+               time_tooltip_format = 0;
+       }
+       if (time1_timezone) {
+               g_free(time1_timezone);
+               time1_timezone = 0;
+       }
+       if (time2_timezone) {
+               g_free(time2_timezone);
+               time2_timezone = 0;
+       }
+       if (time_tooltip_timezone) {
+               g_free(time_tooltip_timezone);
+               time_tooltip_timezone = 0;
+       }
+       if (clock_lclick_command) {
+               g_free(clock_lclick_command);
+               clock_lclick_command = 0;
+       }
+       if (clock_rclick_command) {
+               g_free(clock_rclick_command);
+               clock_rclick_command = 0;
+       }
 }
 
 
index 6714f644365fc5598bc0fa2653ce2ac1043279ab..e86cbf6a9ee90ec450211c65407fc67dd4c2a47b 100644 (file)
@@ -40,6 +40,8 @@ extern int clock_enabled;
 // initialize clock : y position, precision, ...
 void init_clock();
 void init_clock_panel(void *panel);
+
+// freed memory and set default values
 void cleanup_clock();
 
 void draw_clock (void *obj, cairo_t *c);
index 60c14f31716e7c3d3f786f82bcb9f5fada61ced7..30aa6e122f700d614d63b93501ddb58f2f9768aa 100644 (file)
@@ -73,6 +73,7 @@ void init_config()
        Background transparent_bg;
        memset(&transparent_bg, 0, sizeof(Background));
        g_array_append_val(backgrounds, transparent_bg);
+printf("*** init_config()\n");
 
        // tint2 could reload config, so we cleanup objects
        cleanup_systray();
index 411f9121467d203bfe67535e9c8c2d7314d3ea24..97195544069650b52a7845d3f12c24061b618dc6 100644 (file)
@@ -48,7 +48,7 @@ Window net_sel_win = None;
 Systraybar systray;
 int refresh_systray;
 int systray_enabled;
-int systray_max_icon_size = 0;
+int systray_max_icon_size;
 
 // background pixmap if we render ourselves the icons
 static Pixmap render_background = 0;
@@ -95,9 +95,13 @@ void init_systray_panel(void *p)
 void cleanup_systray()
 {
        systray_enabled = 0;
+       systray_max_icon_size = 0;
        systray.area.on_screen = 0;
        free_area(&systray.area);
-       if (render_background) XFreePixmap(server.dsp, render_background);
+       if (render_background) {
+               XFreePixmap(server.dsp, render_background);
+               render_background = 0;
+       }
 }
 
 
index f95001ec2ecd59a7fe33653434cf80291ed3390a..d18d12eea34921e89acfce4bc0786f20f8568cfd 100644 (file)
@@ -53,8 +53,12 @@ extern int systray_enabled;
 extern int systray_max_icon_size;
 
 void init_systray();
+
 void init_systray_panel(void *p);
+
+// freed memory and set default values
 void cleanup_systray();
+
 void draw_systray(void *obj, cairo_t *c);
 void resize_systray(void *obj);
 
index 02c5c8eeefbce5b814544ad10058a3507396734b..38d1f09d29ab2dd4ca731adf6d6e36c21b048d3f 100644 (file)
@@ -166,7 +166,11 @@ void init_taskbar()
        }
 }
 
-void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data) {remove_task(task_get_task(*(Window*)key)); }
+void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
+{
+       remove_task(task_get_task(*(Window*)key));
+}
+
 void cleanup_taskbar()
 {
        Panel *panel;
index 74ee19aacf87f643af8408ad1ccbed36d08d5a08..25a8dd167716908fa64cbd3a14093e923a429f55 100644 (file)
@@ -34,6 +34,8 @@ typedef struct {
 } Global_taskbar;
 
 void init_taskbar();
+
+// freed memory and set default values
 void cleanup_taskbar();
 
 Task *task_get_task (Window win);
This page took 0.032108 seconds and 4 git commands to generate.