From 919aa5eca6bdc79bdb9276aa499c5b612cc28c4d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 5 Feb 2010 09:47:16 -0800 Subject: Managing the root value and the referencing the old root item. --- libdbusmenu-glib/client.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d63278d..b69e984 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -737,6 +737,10 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlNodePtr root = xmlDocGetRootElement(xmldoc); DbusmenuMenuitem * oldroot = priv->root; + if (oldroot != NULL) { + g_object_ref(oldroot); + } + priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); xmlFreeDoc(xmldoc); @@ -752,8 +756,11 @@ parse_layout (DbusmenuClient * client, const gchar * layout) /* Switch the root around */ g_object_ref(priv->root); dbusmenu_menuitem_set_root(priv->root, TRUE); - dbusmenu_menuitem_set_root(oldroot, FALSE); - g_object_unref(oldroot); + + if (oldroot != NULL) { + dbusmenu_menuitem_set_root(oldroot, FALSE); + g_object_unref(oldroot); + } g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); } -- cgit v1.2.3