From e8dcac5e5e1da9eb69210cffde00f896858793ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Mar 2011 21:54:55 -0500 Subject: Don't unref a variant we didn't have a ref to on error --- libdbusmenu-gtk/menuitem.c | 1 - 1 file changed, 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index ca2bc3e..f02e171 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -287,7 +287,6 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke if (g_variant_n_children(wrapper) != 1) { g_warning("Unable to parse shortcut, too many keys"); - g_variant_unref(wrapper); return; } -- cgit v1.2.3 From 980cc3a10a166cd99f9369712489f849732a63e0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Mar 2011 22:06:44 -0500 Subject: Putting in some protections from NULL parameters. --- libdbusmenu-gtk/menuitem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index f02e171..f6c50b6 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -275,6 +275,17 @@ dbusmenu_menuitem_property_set_shortcut_menuitem (DbusmenuMenuitem * menuitem, c void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier) { + guint dummykey; + GdkModifierType dummymodifier; + + if (key == NULL) { + key = &dummykey; + } + + if (modifier == NULL) { + modifier = &dummymodifier; + } + *key = 0; *modifier = 0; -- cgit v1.2.3 From de83592f2bb7a825b4164b68e9a70499416aeb4b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Mar 2011 22:11:25 -0500 Subject: Use loop instead of next --- libdbusmenu-gtk/menuitem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index f6c50b6..9987cef 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -305,7 +305,7 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke g_variant_iter_init(&iter, g_variant_get_child_value(wrapper, 0)); gchar * string; - while(g_variant_iter_next(&iter, "s", &string)) { + while(g_variant_iter_loop(&iter, "s", &string)) { if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_CONTROL) == 0) { *modifier |= GDK_CONTROL_MASK; } else if (g_strcmp0(string, DBUSMENU_MENUITEM_SHORTCUT_ALT) == 0) { @@ -318,8 +318,6 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke GdkModifierType tempmod; gtk_accelerator_parse(string, key, &tempmod); } - - g_free(string); } return; -- cgit v1.2.3 From ad638a2aed595ae3695c0068e3447c811fa91207 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 29 Mar 2011 08:46:45 -0500 Subject: Split out into another variable --- libdbusmenu-gtk/menuitem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 9987cef..0f511bc 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -302,7 +302,8 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } GVariantIter iter; - g_variant_iter_init(&iter, g_variant_get_child_value(wrapper, 0)); + GVariant * child = g_variant_get_child_value(wrapper, 0); + g_variant_iter_init(&iter, child); gchar * string; while(g_variant_iter_loop(&iter, "s", &string)) { @@ -320,6 +321,8 @@ dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * ke } } + g_variant_unref(child); + return; } -- cgit v1.2.3