aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorAlbert Astals <albert.astals@canonical.com>2012-10-26 08:37:44 +0000
committerTarmac <Unknown>2012-10-26 08:37:44 +0000
commit35c7a1b8d2abdd3a8c49e9d2733482571d98d38a (patch)
tree2e0e66b1f2670fd2cc3ca0f648b1399acbe90fb4 /libdbusmenu-glib
parentb914be2afa8fa8d12a83841991701298c558f142 (diff)
parentfa83f46a8bebb0788f2d92b633c0aabcbcc1db09 (diff)
downloadlibdbusmenu-35c7a1b8d2abdd3a8c49e9d2733482571d98d38a.tar.gz
libdbusmenu-35c7a1b8d2abdd3a8c49e9d2733482571d98d38a.tar.bz2
libdbusmenu-35c7a1b8d2abdd3a8c49e9d2733482571d98d38a.zip
Do not reuse menu items if their type is different
The gtk side does not know how to convert from a separator to a standard item, and even if it'd knew it does not make much sense to reuse them since if the types are different you can expect there's little to reuse. Fixes: https://bugs.launchpad.net/bugs/1071321. Approved by Charles Kerr, PS Jenkins bot.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/client.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 237697c..4bb3217 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -2160,8 +2160,29 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem *
for (childsearch = oldchildren; childsearch != NULL; childsearch = g_list_next(childsearch)) {
DbusmenuMenuitem * cs_mi = DBUSMENU_MENUITEM(childsearch->data);
if (childid == dbusmenu_menuitem_get_id(cs_mi)) {
- oldchildren = g_list_remove(oldchildren, cs_mi);
- childmi = cs_mi;
+ GVariantIter iter;
+ gchar * prop;
+ GVariant * value;
+ GVariant * child_props;
+ GVariant * new_type = NULL;
+ GVariant * old_type = NULL;
+
+ child_props = g_variant_get_child_value(child, 1);
+ g_variant_iter_init(&iter, child_props);
+ while (g_variant_iter_loop(&iter, "{sv}", &prop, &value)) {
+ if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) {
+ new_type = value;
+ break;
+ }
+ }
+ g_variant_unref(child_props);
+
+ old_type = dbusmenu_menuitem_property_get_variant(cs_mi, DBUSMENU_MENUITEM_PROP_TYPE);
+ if ((old_type == NULL && new_type == NULL) || (old_type != NULL && new_type != NULL && g_variant_compare(old_type, new_type) == 0)) {
+ // Only recycle the menu item if it's of the same type
+ oldchildren = g_list_remove(oldchildren, cs_mi);
+ childmi = cs_mi;
+ }
break;
}
}