From 2ab9a07ec79b7dd979253340cf7a471048be0c8f Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Tue, 8 Jun 2010 13:36:58 +0200 Subject: [PATCH] Simplify variant builder Build the full return value with one builder, and don't unref the unowned return value! Bug #620954. --- gio/gdbusapplication.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gio/gdbusapplication.c b/gio/gdbusapplication.c index 8b17ce4..00f3213 100644 --- a/gio/gdbusapplication.c +++ b/gio/gdbusapplication.c @@ -51,22 +51,19 @@ application_dbus_method_call (GDBusConnection *connection, GHashTableIter iter; GApplicationAction *value; GVariantBuilder builder; - GVariant *return_args; - GVariant *result; - g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("(a{s(sb)})")); + g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{s(sb)}")); g_hash_table_iter_init (&iter, app->priv->actions); while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&value)) g_variant_builder_add (&builder, "{s(sb)}", value->name, value->description ? value->description : "", value->enabled); + g_variant_builder_close (&builder); - result = g_variant_builder_end (&builder); - return_args = g_variant_new_tuple (&result, 1); - g_dbus_method_invocation_return_value (invocation, return_args); - g_variant_unref (return_args); - g_variant_unref (result); + g_dbus_method_invocation_return_value (invocation, + g_variant_builder_end (&builder)); } else if (strcmp (method_name, "InvokeAction") == 0) { -- 2.7.4