[libdazzle/libdazzle-3-28] variant: fix improper g_variant_parse() usage
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle/libdazzle-3-28] variant: fix improper g_variant_parse() usage
- Date: Sat, 28 Jul 2018 07:54:40 +0000 (UTC)
commit c2b469c5ea8d5c57050fa40a3191bb3e56eb7094
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 28 00:53:28 2018 -0700
variant: fix improper g_variant_parse() usage
g_variant_parse() does not return a variant with a floating reference. So
we must unref them ourselves. Aldo, don't try to ref_sink(), since that
just increments to 2, and is not what we want.
src/actions/dzl-action-group.h | 4 ++--
src/prefs/dzl-preferences-view.c | 4 ----
src/tree/dzl-tree.c | 2 +-
src/util/dzl-gtk.c | 2 +-
4 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/src/actions/dzl-action-group.h b/src/actions/dzl-action-group.h
index 35a1154..7d94067 100644
--- a/src/actions/dzl-action-group.h
+++ b/src/actions/dzl-action-group.h
@@ -86,8 +86,8 @@ _##prefix##_get_action_info (GActionGroup *group,
if (g_strcmp0 (prefix##_actions[i].name, name) == 0) \
{ \
if (prefix##_actions[i].state != NULL) \
- info->state = g_variant_take_ref (g_variant_parse ( \
- NULL, prefix##_actions[i].state, NULL, NULL, NULL)); \
+ info->state = g_variant_parse ( \
+ NULL, prefix##_actions[i].state, NULL, NULL, NULL); \
break; \
} \
} \
diff --git a/src/prefs/dzl-preferences-view.c b/src/prefs/dzl-preferences-view.c
index 683e762..c7ac160 100644
--- a/src/prefs/dzl-preferences-view.c
+++ b/src/prefs/dzl-preferences-view.c
@@ -508,8 +508,6 @@ dzl_preferences_view_add_radio (DzlPreferences *preferences,
if (variant == NULL)
g_warning ("%s", error->message);
- else
- g_variant_ref_sink (variant);
}
widget = g_object_new (DZL_TYPE_PREFERENCES_SWITCH,
@@ -586,8 +584,6 @@ dzl_preferences_view_add_switch (DzlPreferences *preferences,
if (variant == NULL)
g_warning ("%s", error->message);
- else
- g_variant_ref_sink (variant);
}
widget = g_object_new (DZL_TYPE_PREFERENCES_SWITCH,
diff --git a/src/tree/dzl-tree.c b/src/tree/dzl-tree.c
index 4fef2d9..969a195 100644
--- a/src/tree/dzl-tree.c
+++ b/src/tree/dzl-tree.c
@@ -875,7 +875,7 @@ dzl_tree_real_action (DzlTree *self,
const gchar *action_name,
const gchar *param)
{
- GVariant *variant = NULL;
+ g_autoptr(GVariant) variant = NULL;
g_autofree gchar *name = NULL;
g_return_if_fail (DZL_IS_TREE (self));
diff --git a/src/util/dzl-gtk.c b/src/util/dzl-gtk.c
index 4395e66..95ac321 100644
--- a/src/util/dzl-gtk.c
+++ b/src/util/dzl-gtk.c
@@ -90,7 +90,7 @@ dzl_gtk_widget_action_with_string (GtkWidget *widget,
const gchar *name,
const gchar *param)
{
- GVariant *variant = NULL;
+ g_autoptr(GVariant) variant = NULL;
gboolean ret;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]