Simplify variant builder
authorChristian Persch <chpe@gnome.org>
Tue, 8 Jun 2010 11:36:58 +0000 (13:36 +0200)
committerChristian Persch <chpe@gnome.org>
Tue, 8 Jun 2010 15:41:47 +0000 (17:41 +0200)
Build the full return value with one builder, and don't unref the
unowned return value!

Bug #620954.

gio/gdbusapplication.c

index 8b17ce4..00f3213 100644 (file)
@@ -51,22 +51,19 @@ application_dbus_method_call (GDBusConnection       *connection,
       GHashTableIter iter;
       GApplicationAction *value;
       GVariantBuilder builder;
       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_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)
     {
     }
   else if (strcmp (method_name, "InvokeAction") == 0)
     {