[Xfce4-commits] [xfce/xfce4-panel] 13/24: Fix GPtrArray usage in launcher and systray

noreply at xfce.org noreply at xfce.org
Tue Jul 4 00:03:44 CEST 2017


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

o   c   h   o   s   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/xfce4-panel.

commit fd4b03b165ba6e3110014216dc77468401237e4c
Author: Ali Abdallah <ali at xfce.org>
Date:   Sun Jun 25 13:38:30 2017 +0200

    Fix GPtrArray usage in launcher and systray
    
    For some properties, the launcher and systray plugins use a GPtrArray.
    In their _get_property, they set the array to the value using g_value_set_boxed,
    followed by a call to xfconf_array_free, which calls g_value_unset, g_free on each
    array's values and at the end a call to g_ptr_array_free.
    
    This results in xfconf_channel_set_property getting an array with length 0, making
    the preparation of the GVariant fails (xfconf_gvalue_to_gvariant).
    
    This is fixed in both plugins, by using a g_ptr_array_new_full, setting the boxed value
    and releasing the reference count of the array, the array's values are later destroyed
    by the (GDestroyNotify) function. No idea why it worked before with xfconf < 4.13.0.
---
 plugins/launcher/launcher.c | 15 +++++++++++++--
 plugins/systray/systray.c   | 16 ++++++++++++----
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/plugins/launcher/launcher.c b/plugins/launcher/launcher.c
index 55e3af1..de92ffb 100644
--- a/plugins/launcher/launcher.c
+++ b/plugins/launcher/launcher.c
@@ -402,6 +402,17 @@ launcher_plugin_init (LauncherPlugin *plugin)
 
 
 static void
+launcher_free_array_element (gpointer data)
+{
+  GValue *value = (GValue *)data;
+
+  g_value_unset (value);
+  g_free (value);
+}
+
+
+
+static void
 launcher_plugin_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
@@ -416,7 +427,7 @@ launcher_plugin_get_property (GObject    *object,
   switch (prop_id)
     {
     case PROP_ITEMS:
-      array = g_ptr_array_new ();
+      array = g_ptr_array_new_full (1, (GDestroyNotify) launcher_free_array_element);
       for (li = plugin->items; li != NULL; li = li->next)
         {
           tmp = g_new0 (GValue, 1);
@@ -431,7 +442,7 @@ launcher_plugin_get_property (GObject    *object,
           g_ptr_array_add (array, tmp);
         }
       g_value_set_boxed (value, array);
-      xfconf_array_free (array);
+      g_ptr_array_unref (array);
       break;
 
     case PROP_DISABLE_TOOLTIPS:
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index 86c036c..e3061ca 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -257,6 +257,14 @@ systray_plugin_init (SystrayPlugin *plugin)
 }
 
 
+static void
+systray_free_array_element (gpointer data)
+{
+  GValue *value = (GValue *)data;
+
+  g_value_unset (value);
+  g_free (value);
+}
 
 static void
 systray_plugin_get_property (GObject    *object,
@@ -279,17 +287,17 @@ systray_plugin_get_property (GObject    *object,
       break;
 
     case PROP_NAMES_ORDERED:
-      array = g_ptr_array_new ();
+      array = g_ptr_array_new_full (1, (GDestroyNotify) systray_free_array_element);
       g_slist_foreach (plugin->names_ordered, systray_plugin_names_collect_ordered, array);
       g_value_set_boxed (value, array);
-      xfconf_array_free (array);
+      g_ptr_array_unref (array);
       break;
 
     case PROP_NAMES_HIDDEN:
-      array = g_ptr_array_new ();
+      array = g_ptr_array_new_full (1, (GDestroyNotify) systray_free_array_element);
       g_hash_table_foreach (plugin->names_hidden, systray_plugin_names_collect_hidden, array);
       g_value_set_boxed (value, array);
-      xfconf_array_free (array);
+      g_ptr_array_unref (array);
       break;
 
     default:

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


More information about the Xfce4-commits mailing list