From 9e18d8b448cec5204d4d86434a491ff886567957 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 18 May 2011 12:58:11 +0200 Subject: [PATCH] symboliccolor: Allow props == NULL when resolving If props == NULL in gtk_symbolic_color_resolve(), fail sanely for named colors. The docs used to say it was not allowed to pass NULL for named color, but that had problems: 1) You do not know if a color was created that way. This is especially hard for generic users (like language bindings). 2) It wasn't even true. Colors using other symbolic colors would also fail when trying to resolve their named colors, but the docs didn't say so. And because I want to use the function to resolve static colors early where possible, I changed things. --- gtk/gtksymboliccolor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gtk/gtksymboliccolor.c b/gtk/gtksymboliccolor.c index a359fe1fea..d99aa136d3 100644 --- a/gtk/gtksymboliccolor.c +++ b/gtk/gtksymboliccolor.c @@ -474,8 +474,9 @@ _shade_color (GdkRGBA *color, * if @color can't be resolved, it is due to it being defined on * top of a named color that doesn't exist in @props. * - * @props must be non-%NULL if @color was created using - * gtk_symbolic_color_named_new(), but can be omitted in other cases. + * When @props is %NULL, resolving of named colors will fail, so if + * your @color is or references such a color, this function will + * return %FALSE. * * Returns: %TRUE if the color has been resolved * @@ -488,6 +489,7 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { g_return_val_if_fail (color != NULL, FALSE); g_return_val_if_fail (resolved_color != NULL, FALSE); + g_return_val_if_fail (props == NULL || GTK_IS_STYLE_PROPERTIES (props), FALSE); switch (color->type) { @@ -498,7 +500,8 @@ gtk_symbolic_color_resolve (GtkSymbolicColor *color, { GtkSymbolicColor *named_color; - g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE); + if (props == NULL) + return FALSE; named_color = gtk_style_properties_lookup_color (props, color->name);