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>
This commit is contained in:
David Zeuthen 2011-05-11 20:57:54 -04:00
parent d39731724a
commit 5a811135f7
4 changed files with 26 additions and 0 deletions

View 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

View 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.

View 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);

View 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