[Xfce4-commits] [xfce/xfconf] 01/01: Initialize GValue for empty arrays (Bug #13780)

noreply at xfce.org noreply at xfce.org
Fri Jun 8 06:39:17 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   l   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfconf.

commit f4d3a6ab0201157084bd1a8ced2b5bd545e9590c
Author: Ali Abdallah <ali at xfce.org>
Date:   Fri Jun 8 06:38:23 2018 +0200

     Initialize GValue for empty arrays (Bug #13780)
    
    initilize the GValue to G_TYPE_PTR_ARRAY, so that the
    g_value_take_boxed does not fail for empty arrays.
    Patch from ninetls.
---
 common/xfconf-gvaluefuncs.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/common/xfconf-gvaluefuncs.c b/common/xfconf-gvaluefuncs.c
index 38a012b..a775369 100644
--- a/common/xfconf-gvaluefuncs.c
+++ b/common/xfconf-gvaluefuncs.c
@@ -623,30 +623,28 @@ GValue * xfconf_gvariant_to_gvalue (GVariant *in_variant)
         gsize nchild;
         gsize idx = 0;
 
-        nchild = g_variant_n_children (variant);
-
-        if (nchild > 0) {
-            arr = g_ptr_array_new_full(nchild, (GDestroyNotify)xfonf_free_array_elem_val);
+        g_value_init(value, G_TYPE_PTR_ARRAY);
 
-            while (idx < nchild ) {
-                GVariant *v;
-                GValue *arr_val;
+        nchild = g_variant_n_children (variant);
+        arr = g_ptr_array_new_full(nchild, (GDestroyNotify)xfonf_free_array_elem_val);
 
-                arr_val = g_new0(GValue, 1);
+        while (idx < nchild ) {
+            GVariant *v;
+            GValue *arr_val;
 
-                var = g_variant_get_child_value (variant, idx);
-                v = g_variant_get_variant (var);
-                xfconf_basic_gvariant_to_gvalue (v, arr_val);
+            arr_val = g_new0(GValue, 1);
 
-                g_variant_unref (v);
-                g_variant_unref (var);
-                g_ptr_array_add (arr, arr_val);
-                idx++;
-            }
+            var = g_variant_get_child_value (variant, idx);
+            v = g_variant_get_variant (var);
+            xfconf_basic_gvariant_to_gvalue (v, arr_val);
 
-            g_value_init(value, G_TYPE_PTR_ARRAY);
-            g_value_take_boxed(value, arr);
+            g_variant_unref (v);
+            g_variant_unref (var);
+            g_ptr_array_add (arr, arr_val);
+            idx++;
         }
+
+        g_value_take_boxed(value, arr);
     }
     else if (g_variant_is_of_type (variant, G_VARIANT_TYPE("as"))) {
         g_value_init(value, G_TYPE_STRV);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list