diff options
author | Benjamin Otte <otte@redhat.com> | 2016-02-22 04:00:36 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-02-22 04:37:57 +0100 |
commit | 414657100f2c3f56d3304bd28dfd1759971a80dd (patch) | |
tree | 98dcb609595dacc93cfaf696054121736c295eec /gtk/gtkwin32draw.c | |
parent | cdb12fec9e4c5af7dbd4452ea686e41eece20f7e (diff) | |
download | gtk+-414657100f2c3f56d3304bd28dfd1759971a80dd.tar.gz |
win32draw: Use the right checks
The first check was the wrong way around.
The second check made the function look wrong. Invalid ID is actually
the special case that should be handled first, so write the function
like that.
Diffstat (limited to 'gtk/gtkwin32draw.c')
-rw-r--r-- | gtk/gtkwin32draw.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/gtkwin32draw.c b/gtk/gtkwin32draw.c index 16459ce390..6caaa77afb 100644 --- a/gtk/gtkwin32draw.c +++ b/gtk/gtkwin32draw.c @@ -481,7 +481,7 @@ gtk_win32_get_sys_metric_id_for_name (const char *name) int gtk_win32_get_sys_metric (gint id) { - if (id >= 0 && id < G_N_ELEMENTS (win32_default_metrics)) + if (id < 0 || id >= G_N_ELEMENTS (win32_default_metrics)) return 0; if (win32_default_metrics[id].get_value) @@ -558,9 +558,12 @@ void gtk_win32_get_sys_color (gint id, GdkRGBA *color) { - if (id < G_N_ELEMENTS (win32_default_colors)) - *color = win32_default_colors[id].rgba; - else - gdk_rgba_parse (color, "black"); + if (id < 0 || id >= G_N_ELEMENTS (win32_default_colors)) + { + gdk_rgba_parse (color, "black"); + return; + } + + *color = win32_default_colors[id].rgba; } |