[libdazzle] menu-manager: unref GVariant when iterating item values
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] menu-manager: unref GVariant when iterating item values
- Date: Sat, 28 Jul 2018 03:32:19 +0000 (UTC)
commit 5950b1057a40281facdee53379c30772c877cd32
Author: Christian Hergert <chergert redhat com>
Date: Fri Jul 27 20:31:20 2018 -0700
menu-manager: unref GVariant when iterating item values
We are responsible for clearing this, so make sure we do so.
src/menus/dzl-menu-manager.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/menus/dzl-menu-manager.c b/src/menus/dzl-menu-manager.c
index a70c011..89fc4a7 100644
--- a/src/menus/dzl-menu-manager.c
+++ b/src/menus/dzl-menu-manager.c
@@ -154,7 +154,7 @@ model_copy_attributes_to_item (GMenuModel *model,
gint item_index,
GMenuItem *item)
{
- GMenuAttributeIter *iter;
+ g_autoptr(GMenuAttributeIter) iter = NULL;
const gchar *attr_name;
GVariant *attr_value;
@@ -162,10 +162,14 @@ model_copy_attributes_to_item (GMenuModel *model,
g_assert (item_index >= 0);
g_assert (G_IS_MENU_ITEM (item));
- iter = g_menu_model_iterate_item_attributes (model, item_index);
+ if (!(iter = g_menu_model_iterate_item_attributes (model, item_index)))
+ return;
+
while (g_menu_attribute_iter_get_next (iter, &attr_name, &attr_value))
- g_menu_item_set_attribute_value (item, attr_name, attr_value);
- g_object_unref (iter);
+ {
+ g_menu_item_set_attribute_value (item, attr_name, attr_value);
+ g_variant_unref (attr_value);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]