Use g_simple_async_result_{new_,}take_error

Bug #633685.
This commit is contained in:
Christian Persch 2010-09-23 13:02:50 +02:00
parent 63b87b2c26
commit 9e0c07870a
34 changed files with 98 additions and 270 deletions

View File

@ -266,10 +266,7 @@ async_init_thread (GSimpleAsyncResult *res,
GError *error = NULL;
if (!g_initable_init (G_INITABLE (object), cancellable, &error))
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
static void

View File

@ -937,8 +937,7 @@ fill_async_callback (GObject *source_object,
g_simple_async_result_set_op_res_gssize (simple, res);
if (res == -1)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
else
{
@ -1049,14 +1048,13 @@ large_read_callback (GObject *source_object,
/* Only report the error if we've not already read some data */
if (nread < 0 && data->bytes_read == 0)
g_simple_async_result_set_from_error (simple, error);
g_simple_async_result_take_error (simple, error);
else if (error)
g_error_free (error);
if (nread > 0)
data->bytes_read += nread;
if (error)
g_error_free (error);
/* Complete immediately, not in idle, since we're already
* in a mainloop callout
*/
@ -1087,8 +1085,9 @@ read_fill_buffer_callback (GObject *source_object,
result, &error);
if (nread < 0 && data->bytes_read == 0)
g_simple_async_result_set_from_error (simple, error);
g_simple_async_result_take_error (simple, error);
else if (error)
g_error_free (error);
if (nread > 0)
{
@ -1100,9 +1099,6 @@ read_fill_buffer_callback (GObject *source_object,
priv->pos += data->count;
}
if (error)
g_error_free (error);
/* Complete immediately, not in idle, since we're already
* in a mainloop callout
*/
@ -1234,14 +1230,13 @@ large_skip_callback (GObject *source_object,
/* Only report the error if we've not already read some data */
if (nread < 0 && data->bytes_skipped == 0)
g_simple_async_result_set_from_error (simple, error);
g_simple_async_result_take_error (simple, error);
else if (error)
g_error_free (error);
if (nread > 0)
data->bytes_skipped += nread;
if (error)
g_error_free (error);
/* Complete immediately, not in idle, since we're already
* in a mainloop callout
*/
@ -1272,7 +1267,9 @@ skip_fill_buffer_callback (GObject *source_object,
result, &error);
if (nread < 0 && data->bytes_skipped == 0)
g_simple_async_result_set_from_error (simple, error);
g_simple_async_result_take_error (simple, error);
else if (error)
g_error_free (error);
if (nread > 0)
{
@ -1283,9 +1280,6 @@ skip_fill_buffer_callback (GObject *source_object,
priv->pos += data->count;
}
if (error)
g_error_free (error);
/* Complete immediately, not in idle, since we're already
* in a mainloop callout
*/

View File

@ -575,10 +575,7 @@ flush_buffer_thread (GSimpleAsyncResult *result,
}
if (res == FALSE)
{
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
}
g_simple_async_result_take_error (result, error);
}
typedef struct {

View File

@ -970,8 +970,7 @@ g_data_input_stream_read_line_ready (GObject *object,
if (bytes < 0)
/* stream error. */
{
g_simple_async_result_set_from_error (data->simple, error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
data->checked = 0;
}

View File

@ -806,10 +806,7 @@ get_stream_thread_func (GSimpleAsyncResult *res,
cancellable,
&error);
if (data->stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
/**

View File

@ -1026,10 +1026,7 @@ flush_in_thread_func (GSimpleAsyncResult *res,
if (!g_dbus_connection_flush_sync (G_DBUS_CONNECTION (object),
cancellable,
&error))
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
/**
@ -1237,10 +1234,7 @@ close_in_thread_func (GSimpleAsyncResult *res,
if (!g_dbus_connection_close_sync (G_DBUS_CONNECTION (object),
cancellable,
&error))
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
/**
@ -1748,7 +1742,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
error = NULL;
if (!g_dbus_connection_send_message_unlocked (connection, message, flags, out_serial, &error))
{
g_simple_async_result_set_from_error (simple, error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
goto out;
@ -4974,10 +4968,7 @@ g_dbus_connection_call_done (GObject *source,
value = NULL;
if (value == NULL)
{
g_simple_async_result_set_from_error (state->simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (state->simple, error);
else
g_simple_async_result_set_op_res_gpointer (state->simple, value,
(GDestroyNotify) g_variant_unref);
@ -6284,8 +6275,7 @@ bus_get_async_initable_cb (GObject *source_object,
&error))
{
g_assert (error != NULL);
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_object_unref (source_object);
}
else
@ -6335,8 +6325,7 @@ g_bus_get (GBusType bus_type,
if (connection == NULL)
{
g_assert (error != NULL);
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}

View File

@ -153,8 +153,7 @@ _g_socket_read_with_control_messages_ready (GSocket *socket,
else
{
g_assert (error != NULL);
g_simple_async_result_set_from_error (data->simple, error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
}
if (data->from_mainloop)
@ -908,8 +907,7 @@ write_message_async_cb (GObject *source_object,
&error);
if (bytes_written == -1)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
goto out;
@ -1028,8 +1026,7 @@ write_message_continue_writing (MessageToWriteData *data)
g_error_free (error);
goto out;
}
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
goto out;

View File

@ -1140,8 +1140,7 @@ async_init_get_name_owner_cb (GDBusConnection *connection,
}
else
{
g_simple_async_result_set_from_error (data->simple, error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_complete_in_idle (data->simple);
async_init_data_free (data);
goto out;
@ -1265,8 +1264,7 @@ async_init_start_service_by_name_cb (GDBusConnection *connection,
failed:
g_warn_if_fail (error != NULL);
g_simple_async_result_set_from_error (data->simple, error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_complete_in_idle (data->simple);
async_init_data_free (data);
}
@ -1453,8 +1451,7 @@ get_connection_cb (GObject *source_object,
data->callback,
data->user_data,
NULL);
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}
@ -2148,9 +2145,7 @@ reply_cb (GDBusConnection *connection,
&error);
if (error != NULL)
{
g_simple_async_result_set_from_error (simple,
error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
else
{

View File

@ -105,8 +105,7 @@ g_dummy_proxy_resolver_lookup_async (GProxyResolver *resolver,
if (proxies == NULL)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
else
{

View File

@ -4830,10 +4830,7 @@ query_info_async_thread (GSimpleAsyncResult *res,
info = g_file_query_info (G_FILE (object), data->attributes, data->flags, cancellable, &error);
if (info == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->info = info;
}
@ -4906,10 +4903,7 @@ query_filesystem_info_async_thread (GSimpleAsyncResult *res,
info = g_file_query_filesystem_info (G_FILE (object), data->attributes, cancellable, &error);
if (info == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->info = info;
}
@ -4981,10 +4975,7 @@ enumerate_children_async_thread (GSimpleAsyncResult *res,
enumerator = g_file_enumerate_children (G_FILE (object), data->attributes, data->flags, cancellable, &error);
if (enumerator == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->enumerator = enumerator;
}
@ -5046,8 +5037,7 @@ open_read_async_thread (GSimpleAsyncResult *res,
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
g_simple_async_result_take_error (res, error);
return;
}
@ -5055,10 +5045,7 @@ open_read_async_thread (GSimpleAsyncResult *res,
stream = iface->read_fn (G_FILE (object), cancellable, &error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
@ -5112,10 +5099,7 @@ append_to_async_thread (GSimpleAsyncResult *res,
stream = iface->append_to (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
@ -5175,10 +5159,7 @@ create_async_thread (GSimpleAsyncResult *res,
stream = iface->create (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
@ -5259,10 +5240,7 @@ replace_async_thread (GSimpleAsyncResult *res,
&error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->stream = stream;
}
@ -5326,8 +5304,7 @@ open_readwrite_async_thread (GSimpleAsyncResult *res,
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
g_simple_async_result_take_error (res, error);
return;
}
@ -5335,10 +5312,7 @@ open_readwrite_async_thread (GSimpleAsyncResult *res,
stream = iface->open_readwrite (G_FILE (object), cancellable, &error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
@ -5395,8 +5369,7 @@ create_readwrite_async_thread (GSimpleAsyncResult *res,
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
g_simple_async_result_take_error (res, error);
return;
}
@ -5404,10 +5377,7 @@ create_readwrite_async_thread (GSimpleAsyncResult *res,
stream = iface->create_readwrite (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
@ -5488,10 +5458,7 @@ replace_readwrite_async_thread (GSimpleAsyncResult *res,
&error);
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->stream = stream;
}
@ -5566,10 +5533,7 @@ set_display_name_async_thread (GSimpleAsyncResult *res,
file = g_file_set_display_name (G_FILE (object), data->name, cancellable, &error);
if (file == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->file = file;
}
@ -5702,10 +5666,7 @@ find_enclosing_mount_async_thread (GSimpleAsyncResult *res,
mount = g_file_find_enclosing_mount (G_FILE (object), cancellable, &error);
if (mount == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, mount, (GDestroyNotify)g_object_unref);
}
@ -5834,10 +5795,7 @@ copy_async_thread (GIOSchedulerJob *job,
NULL, NULL);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
g_simple_async_result_complete_in_idle (res);
@ -6410,12 +6368,11 @@ load_contents_open_callback (GObject *obj,
}
else
{
res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
data->callback,
data->user_data,
error);
g_simple_async_result_complete (res);
g_error_free (error);
load_contents_data_free (data);
g_object_unref (res);
}
@ -6814,12 +6771,11 @@ replace_contents_open_callback (GObject *obj,
}
else
{
res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
data->callback,
data->user_data,
error);
g_simple_async_result_complete (res);
g_error_free (error);
replace_contents_data_free (data);
g_object_unref (res);
}

View File

@ -718,10 +718,7 @@ close_async_thread (GSimpleAsyncResult *res,
class = G_FILE_ENUMERATOR_GET_CLASS (object);
result = class->close_fn (G_FILE_ENUMERATOR (object), cancellable, &error);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}

View File

@ -309,11 +309,10 @@ load_async_callback (GObject *source_object,
if (stream == NULL)
{
simple = g_simple_async_result_new_from_error (G_OBJECT (data->icon),
simple = g_simple_async_result_new_take_error (G_OBJECT (data->icon),
data->callback,
data->user_data,
error);
g_error_free (error);
}
else
{

View File

@ -421,10 +421,7 @@ query_info_async_thread (GSimpleAsyncResult *res,
_("Stream doesn't support query_info"));
if (info == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->info = info;
}

View File

@ -524,10 +524,7 @@ query_info_async_thread (GSimpleAsyncResult *res,
_("Stream doesn't support query_info"));
if (info == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
else
data->info = info;
}

View File

@ -947,10 +947,7 @@ read_async_thread (GSimpleAsyncResult *res,
op->buffer, op->count_requested,
cancellable, &error);
if (op->count_read == -1)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
static void
@ -1012,10 +1009,7 @@ skip_async_thread (GSimpleAsyncResult *res,
op->count_requested,
cancellable, &error);
if (op->count_skipped == -1)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
typedef struct {
@ -1066,13 +1060,12 @@ skip_callback_wrapper (GObject *source_object,
if (ret == -1)
{
if (data->count_skipped &&
error->domain == G_IO_ERROR &&
error->code == G_IO_ERROR_CANCELLED)
{ /* No error, return partial read */ }
if (data->count_skipped &&
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
/* No error, return partial read */
g_error_free (error);
else
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
/* Complete immediately, not in idle, since we're already in a mainloop callout */
@ -1164,10 +1157,7 @@ close_async_thread (GSimpleAsyncResult *res,
{
result = class->close_fn (G_INPUT_STREAM (object), cancellable, &error);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
}

View File

@ -570,10 +570,7 @@ close_async_thread (GSimpleAsyncResult *res,
{
result = class->close_fn (G_IO_STREAM (object), cancellable, &error);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
}

View File

@ -188,8 +188,7 @@ load_async_thread (GSimpleAsyncResult *res,
if (stream == NULL)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
g_simple_async_result_take_error (res, error);
}
else
{

View File

@ -855,8 +855,7 @@ got_addresses (GObject *source_object,
{
if (error)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
else
{

View File

@ -595,8 +595,7 @@ next_async_resolved_targets (GObject *source_object,
GSimpleAsyncResult *simple = srv_enum->result;
srv_enum->result = NULL;
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
@ -642,8 +641,7 @@ next_async_have_targets (GNetworkServiceAddressEnumerator *srv_enum)
if (srv_enum->error)
{
g_simple_async_result_set_from_error (simple, srv_enum->error);
g_error_free (srv_enum->error);
g_simple_async_result_take_error (simple, srv_enum->error);
srv_enum->error = NULL;
}

View File

@ -595,10 +595,11 @@ async_ready_close_callback_wrapper (GObject *source_object,
{
GSimpleAsyncResult *err;
err = g_simple_async_result_new_from_error (source_object,
err = g_simple_async_result_new_take_error (source_object,
stream->priv->outstanding_callback,
data->user_data,
data->flush_error);
data->flush_error = NULL;
(*stream->priv->outstanding_callback) (source_object,
G_ASYNC_RESULT (err),
@ -1254,10 +1255,7 @@ write_async_thread (GSimpleAsyncResult *res,
op->count_written = class->write_fn (G_OUTPUT_STREAM (object), op->buffer, op->count_requested,
cancellable, &error);
if (op->count_written == -1)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
static void
@ -1321,10 +1319,7 @@ splice_async_thread (GSimpleAsyncResult *result,
cancellable,
&error);
if (op->bytes_copied == -1)
{
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
}
g_simple_async_result_take_error (result, error);
}
static void
@ -1381,10 +1376,7 @@ flush_async_thread (GSimpleAsyncResult *res,
result = class->flush (G_OUTPUT_STREAM (object), cancellable, &error);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
static void
@ -1444,10 +1436,7 @@ close_async_thread (GSimpleAsyncResult *res,
result = class->close_fn (G_OUTPUT_STREAM (object), cancellable, &error);
if (!result)
{
g_simple_async_result_set_from_error (res, error);
g_error_free (error);
}
g_simple_async_result_take_error (res, error);
}
}

View File

@ -393,14 +393,9 @@ dest_hostname_lookup_cb (GObject *object,
result,
&error);
if (priv->dest_ips)
{
save_result (priv);
}
save_result (priv);
else
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
complete_async (priv);
}
@ -459,10 +454,7 @@ address_enumerate_cb (GObject *object,
}
if (error)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
complete_async (priv);
}
@ -483,8 +475,7 @@ proxy_lookup_cb (GObject *object,
if (error)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
g_simple_async_result_take_error (simple, error);
}
else
{

View File

@ -106,10 +106,8 @@ g_socket_address_enumerator_real_next_async (GSocketAddressEnumerator *enumerato
if (address)
g_simple_async_result_set_op_res_gpointer (result, address, NULL);
else if (error)
{
g_simple_async_result_set_from_error (result, error);
g_error_free (error);
}
g_simple_async_result_take_error (result, error);
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}

View File

@ -938,8 +938,7 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
{
if (data->last_error)
{
g_simple_async_result_set_from_error (data->result, data->last_error);
g_error_free (data->last_error);
g_simple_async_result_take_error (data->result, data->last_error);
}
else
{

View File

@ -142,10 +142,7 @@ g_socket_input_stream_read_ready (GSocket *socket,
g_simple_async_result_set_op_res_gssize (simple, result);
if (error)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
if (stream->priv->cancellable)
g_object_unref (stream->priv->cancellable);

View File

@ -710,8 +710,7 @@ accept_ready (GSocket *accept_socket,
}
else
{
g_simple_async_result_set_from_error (data->simple, error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
}
g_simple_async_result_complete_in_idle (data->simple);

View File

@ -144,10 +144,7 @@ g_socket_output_stream_write_ready (GSocket *socket,
g_simple_async_result_set_op_res_gssize (simple, result);
if (error)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
if (stream->priv->cancellable)
g_object_unref (stream->priv->cancellable);

View File

@ -288,9 +288,7 @@ static void
complete_async_from_error (ConnectAsyncData *data, GError *error)
{
GSimpleAsyncResult *simple = data->simple;
g_simple_async_result_set_from_error (data->simple,
error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_set_op_res_gpointer (simple, NULL, NULL);
g_simple_async_result_complete (simple);
g_object_unref (simple);
@ -364,9 +362,7 @@ g_socks4a_proxy_connect_async (GProxy *proxy,
if (data->length < 0)
{
g_simple_async_result_set_from_error (data->simple,
error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_set_op_res_gpointer (simple, NULL, NULL);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);

View File

@ -599,9 +599,7 @@ static void
complete_async_from_error (ConnectAsyncData *data, GError *error)
{
GSimpleAsyncResult *simple = data->simple;
g_simple_async_result_set_from_error (data->simple,
error);
g_error_free (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_set_op_res_gpointer (simple, NULL, NULL);
g_simple_async_result_complete (simple);
g_object_unref (simple);

View File

@ -210,7 +210,7 @@ close_async_data_free (CloseAsyncData *data)
static void
async_close_finish (CloseAsyncData *data,
GError *error,
GError *error /* consumed */,
gboolean in_mainloop)
{
GIOStreamClass *parent = G_IO_STREAM_CLASS (g_tcp_connection_parent_class);
@ -223,17 +223,14 @@ async_close_finish (CloseAsyncData *data,
if (error)
{
parent->close_fn (stream, data->cancellable, NULL);
g_simple_async_result_set_from_error (data->res, error);
g_simple_async_result_take_error (data->res, error);
}
else
{
my_error = NULL;
parent->close_fn (stream, data->cancellable, &my_error);
if (my_error)
{
g_simple_async_result_set_from_error (data->res, my_error);
g_error_free (my_error);
}
g_simple_async_result_take_error (data->res, my_error);
}
if (in_mainloop)
@ -260,7 +257,6 @@ close_read_ready (GSocket *socket,
else
{
async_close_finish (data, error, TRUE);
g_error_free (error);
return FALSE;
}
}
@ -306,7 +302,6 @@ g_tcp_connection_close_async (GIOStream *stream,
if (!g_socket_shutdown (socket, FALSE, TRUE, &error))
{
async_close_finish (data, error, FALSE);
g_error_free (error);
close_async_data_free (data);
return;
}

View File

@ -462,10 +462,7 @@ read_async_cb (ReadAsyncData *data,
g_simple_async_result_set_op_res_gssize (simple, count_read);
if (count_read == -1)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
/* Complete immediately, not in idle, since we're already in a mainloop callout */
g_simple_async_result_complete (simple);
@ -601,10 +598,7 @@ close_async_cb (CloseAsyncData *data)
g_unix_input_stream_close_async);
if (!result)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
/* Complete immediately, not in idle, since we're already in a mainloop callout */
g_simple_async_result_complete (simple);

View File

@ -370,7 +370,7 @@ eject_unmount_do_cb (gpointer user_data)
handle_error:
if (error != NULL) {
GSimpleAsyncResult *simple;
simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_mount),
simple = g_simple_async_result_new_take_error (G_OBJECT (data->unix_mount),
data->callback,
data->user_data,
error);
@ -384,7 +384,6 @@ handle_error:
g_io_channel_unref (data->error_channel);
g_strfreev (data->argv);
g_error_free (error);
g_free (data);
}

View File

@ -449,10 +449,7 @@ write_async_cb (WriteAsyncData *data,
g_simple_async_result_set_op_res_gssize (simple, count_written);
if (count_written == -1)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
/* Complete immediately, not in idle, since we're already in a mainloop callout */
g_simple_async_result_complete (simple);
@ -557,10 +554,7 @@ close_async_cb (CloseAsyncData *data)
g_unix_output_stream_close_async);
if (!result)
{
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
g_simple_async_result_take_error (simple, error);
/* Complete immediately, not in idle, since we're already in a mainloop callout */
g_simple_async_result_complete (simple);

View File

@ -232,8 +232,7 @@ request_cancelled (GCancellable *cancellable,
req->qy = NULL;
g_cancellable_set_error_if_cancelled (cancellable, &error);
g_simple_async_result_set_from_error (req->async_result, error);
g_error_free (error);
g_simple_async_result_take_error (req->async_result, error);
g_unix_resolver_request_complete (req);
}
@ -303,10 +302,7 @@ lookup_by_name_process (GUnixResolverRequest *req)
freeaddrinfo (res);
if (error)
{
g_simple_async_result_set_from_error (req->async_result, error);
g_error_free (error);
}
g_simple_async_result_take_error (req->async_result, error);
}
static void
@ -373,10 +369,7 @@ lookup_by_address_process (GUnixResolverRequest *req)
host, retval, &error);
if (error)
{
g_simple_async_result_set_from_error (req->async_result, error);
g_error_free (error);
}
g_simple_async_result_take_error (req->async_result, error);
}
static void
@ -453,10 +446,7 @@ lookup_service_process (GUnixResolverRequest *req)
_g_asyncns_freeanswer (answer);
if (error)
{
g_simple_async_result_set_from_error (req->async_result, error);
g_error_free (error);
}
g_simple_async_result_take_error (req->async_result, error);
}
static void

View File

@ -410,7 +410,7 @@ handle_error:
if (error != NULL)
{
GSimpleAsyncResult *simple;
simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_volume),
simple = g_simple_async_result_new_take_error (G_OBJECT (data->unix_volume),
data->callback,
data->user_data,
error);
@ -423,7 +423,6 @@ handle_error:
if (data->error_channel != NULL)
g_io_channel_unref (data->error_channel);
g_error_free (error);
g_free (data);
}
}