aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index f5546a2..c0d3b7a 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -35,6 +35,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "client.h"
#include "menuitem.h"
+#include "menuitem-private.h"
#include "client-menuitem.h"
#include "dbusmenu-client.h"
#include "server-marshal.h"
@@ -366,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;
}
@@ -531,6 +533,9 @@ build_proxies (DbusmenuClient * client)
static gint
parse_node_get_id (xmlNodePtr node)
{
+ if (node->type != XML_ELEMENT_NODE) {
+ return -1;
+ }
if (g_strcmp0((gchar *)node->name, "menu") != 0) {
/* This kills some nodes early */
g_warning("XML Node is not 'menu' it is '%s'", node->name);
@@ -573,10 +578,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;
}
@@ -605,6 +612,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;
@@ -617,6 +626,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);
@@ -624,6 +634,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;
@@ -645,12 +656,13 @@ menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GEr
#ifdef MASSIVEDEBUGGING
g_debug("Client has realized a menuitem: %d", dbusmenu_menuitem_get_id(propdata->item));
#endif
- g_signal_emit(G_OBJECT(propdata->item), DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID, 0, TRUE);
+ dbusmenu_menuitem_set_realized(propdata->item);
if (!handled) {
g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE);
}
+ g_object_unref(propdata->item);
g_free(propdata);
return;
@@ -748,7 +760,6 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it
if (parent != NULL) {
dbusmenu_menuitem_child_delete(parent, item);
}
- g_object_unref(G_OBJECT(item));
item = NULL;
}
@@ -767,13 +778,16 @@ 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.");
}
} else {
/* 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);
}
@@ -807,6 +821,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);
}
@@ -844,9 +859,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);
@@ -864,17 +876,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;
}