]> Dogcows Code - chaz/tint2/commitdiff
fixed segfault
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 1 Sep 2009 15:56:52 +0000 (15:56 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 1 Sep 2009 15:56:52 +0000 (15:56 +0000)
ChangeLog
src/config.c
src/taskbar/task.c
src/taskbar/task.h
src/util/common.c
src/util/common.h

index 27d4567a301ca63a68e20eb2243a757c6c833271..354576c53cad481965a1c10f39e3d922d5de596f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-09-01
+- fixed segfault
+
 2009-08-30
 - detect pid of process owning the systray
 
index fce3ff98ea1cbb7fd1521049f4639ee6bb514308..931dc388d82bc40f6db99bd684f13f87944e70da 100644 (file)
@@ -348,7 +348,7 @@ void add_entry (char *key, char *value)
                        panel_config->battery.area.on_screen = 1;
 #else
                if(atoi(value) == 1)
-                       printf("tint2 is build without battery support\n");
+                       fprintf(stderr, "tint2 is build without battery support\n");
 #endif
    }
    else if (strcmp (key, "battery_low_status") == 0) {
index ff0bd500ddca9a7d07e75d3825e7097c85a97277..06c85aba4129714573ee8f3d323af763a3a70afd 100644 (file)
@@ -193,15 +193,16 @@ void get_icon (Task *tsk)
                // DATA32 is provided by imlib2
                tsk->icon_data = malloc (w * h * sizeof (DATA32));
 
+               if (tsk->icon_data) {
 #ifdef __x86_64__
-               int length = tsk->icon_width * tsk->icon_height;
-               int i;
-               for (i = 0; i < length; ++i)
-                       tsk->icon_data[i] =  tmp_data[i];
+                       int length = tsk->icon_width * tsk->icon_height;
+                       int i;
+                       for (i = 0; i < length; ++i)
+                               tsk->icon_data[i] =  tmp_data[i];
 #else
-               memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32));
+                       memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32));
 #endif
-
+               }
                XFree (data);
    }
    else {
@@ -229,20 +230,23 @@ void get_icon (Task *tsk)
                        tsk->icon_width = imlib_image_get_width();
                        tsk->icon_height = imlib_image_get_height();
                        tsk->icon_data = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));
-                       memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));
+                       if (tsk->icon_data)
+                               memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));
                        imlib_free_image();
                }
                XFree(hints);
    }
 
-       tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));
-       memcpy (tsk->icon_data_active, tsk->icon_data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));
+       if (tsk->icon_data) {
+               tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32));
+               memcpy (tsk->icon_data_active, tsk->icon_data, tsk->icon_width * tsk->icon_height * sizeof (DATA32));
 
-       if (panel->g_task.hue != 0 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) {
-               adjust_hsb(tsk->icon_data, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue/100, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100);
-       }
-       if (panel->g_task.hue_active != 0 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) {
-               adjust_hsb(tsk->icon_data_active, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue_active/100, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100);
+               if (panel->g_task.hue != 0 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) {
+                       adjust_hsb(tsk->icon_data, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue/100, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100);
+               }
+               if (panel->g_task.hue_active != 0 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) {
+                       adjust_hsb(tsk->icon_data_active, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue_active/100, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100);
+               }
        }
 }
 
index 051c7198472360ce1cf114ea5f8dda5dcfce06f0..f0cefe2a705054a968ad28d3561661c607bf6863 100644 (file)
@@ -49,8 +49,8 @@ typedef struct {
        // ARGB icon
        unsigned int *icon_data;
        unsigned int *icon_data_active;
-       int icon_width;
-       int icon_height;
+       unsigned int icon_width;
+       unsigned int icon_height;
        char *title;
 } Task;
 
index 31c2d2eb2d67cafc67d39777bde97a41f9da5672..f0f6b54886c807615de62abb7b0a27b3adb027a2 100644 (file)
 
 
 
-void adjust_hsb(unsigned int *data, int w, int h, float hu, float satur, float bright)
+void adjust_hsb(DATA32 *data, int w, int h, float hu, float satur, float bright)
 {
-       unsigned int *pt = data;
-       int x, y;
+       unsigned int x, y;
        unsigned int a, r, g, b, argb;
+       unsigned long id;
        int cmax, cmin;
        float h2, f, p, q, t;
        float hue, saturation, brightness;
        float redc, greenc, bluec;
 
-
        for(y = 0; y < h; y++) {
-               for(x = 0; x < w; x++) {
-                       argb = pt[y * h + x];
+               for(id = y * w, x = 0; x < w; x++, id++) {
+                       argb = data[id];
                        a = (argb >> 24) & 0xff;
                        r = (argb >> 16) & 0xff;
                        g = (argb >> 8) & 0xff;
@@ -134,7 +133,7 @@ void adjust_hsb(unsigned int *data, int w, int h, float hu, float satur, float b
                        argb = (argb << 8) + r;
                        argb = (argb << 8) + g;
                        argb = (argb << 8) + b;
-                       pt[y * h + x] = argb;
+                       data[id] = argb;
                }
        }
 }
index 4e6abb767aef0d18dc6375d8975916bb62f73fa4..a2a0c762708dac146cd984e9bff900e63db2aa91 100644 (file)
@@ -9,6 +9,7 @@
 
 #define WM_CLASS_TINT   "panel"
 
+#include <Imlib2.h>
 #include "area.h"
 
 /*
@@ -50,7 +51,7 @@ typedef struct config_color
 
 
 // adjust HSB on an ARGB icon
-void adjust_hsb(unsigned int *data, int w, int h, float hue, float satur, float bright);
+void adjust_hsb(DATA32 *data, int w, int h, float hue, float satur, float bright);
 
 
 
This page took 0.03115 seconds and 4 git commands to generate.