diff options
author | Benjamin Berg <benjamin@sipsolutions.net> | 2007-11-02 14:50:15 (GMT) |
---|---|---|
committer | Benjamin Berg <benjamin@sipsolutions.net> | 2007-11-02 14:50:15 (GMT) |
commit | 0763fefc48e05a061a679221c038751721b204ad (patch) | |
tree | 02b73f8eb04392d4dd2138468fcbb17a138fe7ae /gtk | |
parent | 093d35d6f8c3d18c77022f9ada7676d5e9cf1c06 (diff) |
Prevent a division by zero when making icons insensitive.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/engine/sugar-utils.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gtk/engine/sugar-utils.c b/gtk/engine/sugar-utils.c index 776b1ef..f5525ea 100644 --- a/gtk/engine/sugar-utils.c +++ b/gtk/engine/sugar-utils.c @@ -81,9 +81,17 @@ sugar_get_insensitive_icon (GdkPixbuf *icon, } } - /* Shift the base value, to whatever we really need to adjust to. */ - base = base - range / 2; - mult = (range << 8) / (max_color_value - min_color_value); + /* Shift the base value to the lower side of the range */ + + if (max_color_value - min_color_value > 0) { + base = base - range / 2; + mult = (range << 8) / (max_color_value - min_color_value); + } else { + /* There is only one color, just fill everything with base. + * Se setting mult to 0 means that the old pixel value will just + * be discarted. */ + mult = 0; + } for (y = 0; y < height; y++) { pixel = pixels + y*rowstride; |