Add g_dbus_method_invocation_take_error() convenience method
authorDavid Zeuthen <davidz@redhat.com>
Thu, 12 May 2011 00:57:54 +0000 (20:57 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Thu, 12 May 2011 00:57:54 +0000 (20:57 -0400)
Similar in spirit to g_simple_async_result_take_error().

Signed-off-by: David Zeuthen <davidz@redhat.com>
docs/reference/gio/gio-sections.txt
gio/gdbusmethodinvocation.c
gio/gdbusmethodinvocation.h
gio/gio.symbols

index af1700973964277552b2178447e24ff859d73970..cacd0121468fdd1b019c7fe9378b2e428c3efccd 100644 (file)
@@ -2518,6 +2518,7 @@ g_dbus_method_invocation_return_error_valist
 g_dbus_method_invocation_return_error_literal
 g_dbus_method_invocation_return_gerror
 g_dbus_method_invocation_return_dbus_error
+g_dbus_method_invocation_take_error
 <SUBSECTION Standard>
 G_DBUS_METHOD_INVOCATION
 G_IS_DBUS_METHOD_INVOCATION
index c3daf912fb5272586302b24ade75ed7b494c40fa..6dd7155d9c78e40b46c8f95fea4dc34aac6712ea 100644 (file)
@@ -555,6 +555,28 @@ g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation,
   g_free (dbus_error_name);
 }
 
+/**
+ * g_dbus_method_invocation_take_error: (skip)
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @error: (transfer full): A #GError.
+ *
+ * Like g_dbus_method_invocation_return_gerror() but takes ownership
+ * of @error so the caller does not need to free it.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ *
+ * Since: 2.30
+ */
+void
+g_dbus_method_invocation_take_error (GDBusMethodInvocation *invocation,
+                                     GError                *error)
+{
+  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
+  g_return_if_fail (error != NULL);
+  g_dbus_method_invocation_return_gerror (invocation, error);
+  g_error_free (error);
+}
+
 /**
  * g_dbus_method_invocation_return_dbus_error:
  * @invocation: (transfer full): A #GDBusMethodInvocation.
index 550313e8bff7d9521466d67dc581c0117cd743de..8b8d050cfc6e9056f8596bd56ac14ad344e56d48 100644 (file)
@@ -64,6 +64,8 @@ void                   g_dbus_method_invocation_return_error_literal (GDBusMetho
                                                                       const gchar           *message);
 void                   g_dbus_method_invocation_return_gerror        (GDBusMethodInvocation *invocation,
                                                                       const GError          *error);
+void                   g_dbus_method_invocation_take_error           (GDBusMethodInvocation *invocation,
+                                                                      GError                *error);
 void                   g_dbus_method_invocation_return_dbus_error    (GDBusMethodInvocation *invocation,
                                                                       const gchar           *error_name,
                                                                       const gchar           *error_message);
index 59e1a143d83e3ba17c84afb99b0d1acd7286201d..176666d18f9f242ccc03db3086fda78ffd191c69 100644 (file)
@@ -1824,6 +1824,7 @@ g_dbus_method_invocation_return_error
 g_dbus_method_invocation_return_error_literal
 g_dbus_method_invocation_return_error_valist
 g_dbus_method_invocation_return_gerror
+g_dbus_method_invocation_take_error
 g_dbus_method_invocation_return_value
 #endif
 #endif