From 623b9c346ee991dfbff7fe89ff80834127a39014 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 10:43:31 -0500 Subject: Unreffing the object after it's been put into a menu. --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d61b1ae..910f9a1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -810,6 +810,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it dbusmenu_menuitem_child_delete(item, childmi); } dbusmenu_menuitem_child_add_position(item, newchildmi, position); + g_object_unref(newchildmi); } else { dbusmenu_menuitem_child_reorder(item, childmi, position); } -- cgit v1.2.3 From 6085d46272fb067b475f433ecf5a5477dfa4e721 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 10:47:39 -0500 Subject: Since we already have a ref to root, we don't need to make another. --- libdbusmenu-glib/client.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 910f9a1..f5e7115 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -848,9 +848,6 @@ 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); -- cgit v1.2.3 From e606dae698cb9a4e15fdc260c68744cbee7c3c82 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 11:04:16 -0500 Subject: Reffing oldroot again. --- libdbusmenu-glib/client.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f5e7115..910f9a1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -848,6 +848,9 @@ 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); -- cgit v1.2.3 From 541193c9c95a4ee22286a9f43abf05741361f702 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 11:50:20 -0500 Subject: Removing the unref that was causing issues so that we can remove an extra ref of the root item. --- libdbusmenu-glib/client.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 910f9a1..c8706ac 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -749,8 +749,6 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it if (parent != NULL) { dbusmenu_menuitem_child_delete(parent, item); } - /* XXX: Should this be an unref? Who's reffing this that it exists without a parent? */ - g_object_unref(G_OBJECT(item)); item = NULL; } @@ -848,9 +846,6 @@ 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); -- cgit v1.2.3 From e45ecac9a2dad70c782c33e8d2f9b3ce295238a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 12:13:20 -0500 Subject: Adding references when calling the properties callbacks as items could get destroyed in transit. --- libdbusmenu-glib/client.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c8706ac..3df5c6a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -367,6 +367,7 @@ id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) gchar * properties[1] = {NULL}; /* This gets them all */ g_debug("Getting properties"); + g_object_ref(menuitem); org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); return; } @@ -574,10 +575,12 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError g_return_if_fail(DBUSMENU_IS_MENUITEM(data)); if (error != NULL) { g_warning("Error getting properties on a menuitem: %s", error->message); + g_object_unref(data); return; } g_hash_table_foreach(properties, get_properties_helper, data); g_hash_table_destroy(properties); + g_object_unref(data); return; } @@ -606,6 +609,8 @@ menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, if (!have_error) { menuitem_get_properties_cb(proxy, properties, error, data); + } else { + g_object_unref(data); } return; @@ -618,6 +623,7 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr { if (error != NULL) { g_warning("Error getting properties on a new menuitem: %s", error->message); + g_object_unref(data); return; } g_return_if_fail(data != NULL); @@ -625,6 +631,7 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr newItemPropData * propdata = (newItemPropData *)data; DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client); + g_object_ref(propdata->item); menuitem_get_properties_cb (proxy, properties, error, propdata->item); gboolean handled = FALSE; @@ -652,6 +659,7 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE); } + g_object_unref(propdata->item); g_free(propdata); return; @@ -767,6 +775,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it propdata->parent = parent; gchar * properties[1] = {NULL}; /* This gets them all */ + g_object_ref(item); org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); } else { g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); @@ -775,6 +784,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Refresh the properties */ /* XXX: We shouldn't need to get the properties everytime we reuse an entry */ gchar * properties[1] = {NULL}; /* This gets them all */ + g_object_ref(item); org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item); } -- cgit v1.2.3 From e26f80a52f0453ee7efaca86487f5e04a17fd35b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 12:21:02 -0500 Subject: Now that we're not reffing the root locally, we need to only unref it if we're changing roots --- libdbusmenu-glib/client.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 3df5c6a..d2ba541 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -873,17 +873,14 @@ parse_layout (DbusmenuClient * client, const gchar * layout) clean up that old root */ if (oldroot != NULL) { dbusmenu_menuitem_set_root(oldroot, FALSE); + g_object_unref(oldroot); + oldroot = NULL; } /* If the root changed we can signal that */ g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); } - /* We need to unref it in this function no matter */ - if (oldroot != NULL) { - g_object_unref(oldroot); - } - return 1; } -- cgit v1.2.3