paramspec: Fix array validation logic
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 15 Mar 2017 21:31:39 +0000 (17:31 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 24 Mar 2017 17:43:34 +0000 (13:43 -0400)
A paramspec validation should modify the content to match what the spec
requires and return TURE if a modification happened. This previous
implementation would only fix the first element of the array and return.
It was also return TRUE for empty array, while no modification was
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=780111

gst/gstparamspecs.c

index 66de3bd..7326aa0 100644 (file)
@@ -233,6 +233,7 @@ static gboolean
 _gst_param_array_validate (GParamSpec * pspec, GValue * value)
 {
   GstParamSpecArray *aspec = GST_PARAM_SPEC_ARRAY_LIST (pspec);
+  gboolean ret = FALSE;
 
   /* ensure array values validity against a present element spec */
   if (aspec->element_spec) {
@@ -249,15 +250,16 @@ _gst_param_array_validate (GParamSpec * pspec, GValue * value)
           g_value_unset (element);
         g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
         g_param_value_set_default (element_spec, element);
-        return FALSE;
+        ret = TRUE;
       }
+
       /* validate array value against element_spec */
-      if (!g_param_value_validate (element_spec, element))
-        return FALSE;
+      if (g_param_value_validate (element_spec, element))
+        ret = TRUE;
     }
   }
 
-  return TRUE;
+  return ret;
 }
 
 static gint