From 62b028c0f6cff245f8781a5a4e769be20b2afba1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Feb 2012 12:44:09 -0600 Subject: Because of the change of inhash above we could have hash_variant be NULL here --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 30ae277..18db4ef 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1222,7 +1222,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro but we're actually replacing it no matter. This is so that the variant passed in sticks around which the caller may expect. They shouldn't, but it's low cost to remove bugs. */ - if (!inhash || !g_variant_equal(hash_variant, value)) { + if (!inhash || (hash_variant != NULL && !g_variant_equal(hash_variant, value))) { replaced = TRUE; } -- cgit v1.2.3 From c3467a14ee0ff76b51d5771614153cc6810352ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Feb 2012 12:58:29 -0600 Subject: Making it so that we ref_sink() the variants so that when we unref them later we're not in a race condition with the gdbus thread --- libdbusmenu-glib/server.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4890d37..c992085 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -990,6 +990,7 @@ menuitem_property_idle (gpointer user_data) /* these are going to be standard references in all code paths and must be unrefed */ GVariant * megadata[2]; gboolean gotsomething = FALSE; + gboolean error_nosend = FALSE; if (item_init) { megadata[0] = g_variant_builder_end(&itembuilder); @@ -1002,6 +1003,10 @@ menuitem_property_idle (gpointer user_data) if (error != NULL) { g_warning("Unable to parse '[ ]' as a 'a(ia{sv})': %s", error->message); g_error_free(error); + megadata[0] = NULL; + error_nosend = TRUE; + } else { + g_variant_ref_sink(megadata[0]); } } @@ -1016,10 +1021,14 @@ menuitem_property_idle (gpointer user_data) if (error != NULL) { g_warning("Unable to parse '[ ]' as a 'a(ias)': %s", error->message); g_error_free(error); + megadata[1] = NULL; + error_nosend = TRUE; + } else { + g_variant_ref_sink(megadata[1]); } } - if (gotsomething && priv->dbusobject != NULL && priv->bus != NULL) { + if (gotsomething && !error_nosend && priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, NULL, priv->dbusobject, @@ -1029,8 +1038,13 @@ menuitem_property_idle (gpointer user_data) NULL); } - g_variant_unref(megadata[0]); - g_variant_unref(megadata[1]); + if (megadata[0] != NULL) { + g_variant_unref(megadata[0]); + } + + if (megadata[1] != NULL) { + g_variant_unref(megadata[1]); + } /* Clean everything up */ prop_array_teardown(priv->prop_array); -- cgit v1.2.3 From 29a58948a274ca3cff7da3b32ad97d47cef012c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Feb 2012 16:20:06 -0600 Subject: Ensure that we only return the invocation one way --- libdbusmenu-glib/server.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4890d37..a9ff311 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1595,7 +1595,6 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); if (mi == NULL) { - g_dbus_method_invocation_return_error(invocation, error_quark(), INVALID_MENUITEM_ID, @@ -1605,17 +1604,17 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i g_variant_unref(data); } else { - idle_event_t * event_data = g_new0(idle_event_t, 1); event_data->mi = g_object_ref(mi); - event_data->eventid = etype; + event_data->eventid = etype; /* give away our allocation */ event_data->timestamp = ts; event_data->variant = data; /* give away our reference */ g_timeout_add(0, event_local_handler, event_data); + + g_dbus_method_invocation_return_value(invocation, NULL); } - g_dbus_method_invocation_return_value(invocation, NULL); return; } -- cgit v1.2.3 From 637508a520e01f6b8c7822e37445cda2618087cf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Feb 2012 08:02:10 -0600 Subject: Actually checking the NULL case properly --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a2330d1..6524f02 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -395,7 +395,7 @@ dbusmenu_client_dispose (GObject *object) /* Only used for queueing up a new command, so we can just drop this array. */ - if (priv->delayed_property_list == NULL) { + if (priv->delayed_property_list != NULL) { gchar ** dataregion = (gchar **)g_array_free(priv->delayed_property_list, FALSE); if (dataregion != NULL) { g_strfreev(dataregion); @@ -403,7 +403,7 @@ dbusmenu_client_dispose (GObject *object) priv->delayed_property_list = NULL; } - if (priv->delayed_property_listeners == NULL) { + if (priv->delayed_property_listeners != NULL) { gint i; GError * localerror = NULL; -- cgit v1.2.3 From 54a15536a0eb93f210eb2aa74272b1bfa3b4284a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Feb 2012 08:24:45 -0600 Subject: Removing useless const on dbusmenu_server_get_icon_paths() --- libdbusmenu-glib/server.c | 2 +- libdbusmenu-glib/server.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4890d37..a409bd9 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1809,7 +1809,7 @@ dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) * memory managed by the server. Duplicate if you want * to keep them. */ -const GStrv +GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server) { g_return_val_if_fail(DBUSMENU_IS_SERVER(server), NULL); diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 5feb09b..d482a10 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -167,7 +167,7 @@ void dbusmenu_server_set_text_direction (DbusmenuServer * DbusmenuStatus dbusmenu_server_get_status (DbusmenuServer * server); void dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status); -const GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server); +GStrv dbusmenu_server_get_icon_paths (DbusmenuServer * server); void dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths); -- cgit v1.2.3 From 1f23f41e8f29105abad00412ff2776775f969ac4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Feb 2012 08:26:02 -0600 Subject: Removing useless const on dbusmenu_client_get_icon_paths() --- libdbusmenu-glib/client.c | 2 +- libdbusmenu-glib/client.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a2330d1..ff5c51a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -2210,7 +2210,7 @@ dbusmenu_client_get_status (DbusmenuClient * client) * memory managed by the client. Duplicate if you want * to keep them. */ -const GStrv +GStrv dbusmenu_client_get_icon_paths (DbusmenuClient * client) { g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), NULL); diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 1cb9ee5..d0fca32 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -212,7 +212,7 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli GDestroyNotify destroy_func); DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client); DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient * client); -const GStrv dbusmenu_client_get_icon_paths (DbusmenuClient * client); +GStrv dbusmenu_client_get_icon_paths (DbusmenuClient * client); /** SECTION:client -- cgit v1.2.3