[gtk+] styleproperties: Validate values when setting them



commit 0a368fe622b41963cea587a7444362d5a8eaad68
Author: Benjamin Otte <otte redhat com>
Date:   Sat May 21 19:43:11 2011 +0200

    styleproperties: Validate values when setting them
    
    Note that validation is not necessary when resolving, because all values
    are valid for those cases.

 gtk/gtkstyleproperties.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 0bfd3ae..99bb341 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -533,6 +533,8 @@ _gtk_style_properties_set_property_by_pspec (GtkStyleProperties *props,
     }
 
   g_value_copy (value, val);
+  if (pspec->value_type == value_type)
+    g_param_value_validate (pspec, val);
 }
 
 /**
@@ -625,6 +627,7 @@ gtk_style_properties_set_valist (GtkStyleProperties *props,
 
       G_VALUE_COLLECT_INIT (val, node->pspec->value_type,
                             args, 0, &error);
+      g_param_value_validate (node->pspec, val);
       if (error)
         {
           g_warning ("Could not set style property \"%s\": %s", property_name, error);
@@ -872,10 +875,7 @@ gtk_style_properties_get_property (GtkStyleProperties *props,
   g_value_init (value, node->pspec->value_type);
 
   if (val)
-    {
-      g_value_copy (val, value);
-      g_param_value_validate (node->pspec, value);
-    }
+    g_value_copy (val, value);
   else
     lookup_default_value (node, value);
 
@@ -931,7 +931,6 @@ gtk_style_properties_get_valist (GtkStyleProperties *props,
 
       if (val)
         {
-          g_param_value_validate (node->pspec, val);
           G_VALUE_LCOPY (val, args, 0, &error);
         }
       else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]