[glib] Add g_dbus_method_invocation_take_error() convenience method



commit 5a811135f73057b81ef7080022d313bb58ee8419
Author: David Zeuthen <davidz redhat com>
Date:   Wed May 11 20:57:54 2011 -0400

    Add g_dbus_method_invocation_take_error() convenience method
    
    Similar in spirit to g_simple_async_result_take_error().
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 docs/reference/gio/gio-sections.txt |    1 +
 gio/gdbusmethodinvocation.c         |   22 ++++++++++++++++++++++
 gio/gdbusmethodinvocation.h         |    2 ++
 gio/gio.symbols                     |    1 +
 4 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index af17009..cacd012 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -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
diff --git a/gio/gdbusmethodinvocation.c b/gio/gdbusmethodinvocation.c
index c3daf91..6dd7155 100644
--- a/gio/gdbusmethodinvocation.c
+++ b/gio/gdbusmethodinvocation.c
@@ -556,6 +556,28 @@ g_dbus_method_invocation_return_gerror (GDBusMethodInvocation *invocation,
 }
 
 /**
+ * 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.
  * @error_name: A valid D-Bus error name.
diff --git a/gio/gdbusmethodinvocation.h b/gio/gdbusmethodinvocation.h
index 550313e..8b8d050 100644
--- a/gio/gdbusmethodinvocation.h
+++ b/gio/gdbusmethodinvocation.h
@@ -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);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 59e1a14..176666d 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]