Commit ba45e369 authored by Christian Persch's avatar Christian Persch

Add g_simple_async_report_take_gerror_in_idle

... and use it where appropriate. Saves an extra GError copy.

Bug #633686.
parent 9e0c0787
......@@ -1172,6 +1172,7 @@ g_simple_async_result_set_error
g_simple_async_result_set_error_va
g_simple_async_report_error_in_idle
g_simple_async_report_gerror_in_idle
g_simple_async_report_take_gerror_in_idle
<SUBSECTION Standard>
GSimpleAsyncResultClass
G_SIMPLE_ASYNC_RESULT
......
......@@ -496,11 +496,10 @@ g_buffered_input_stream_fill_async (GBufferedInputStream *stream,
if (!g_input_stream_set_pending (G_INPUT_STREAM (stream), &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -215,11 +215,10 @@ g_file_input_stream_query_info_async (GFileInputStream *stream,
if (!g_input_stream_set_pending (input_stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -227,11 +227,10 @@ g_file_io_stream_query_info_async (GFileIOStream *stream,
if (!g_io_stream_set_pending (io_stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -225,11 +225,10 @@ g_file_output_stream_query_info_async (GFileOutputStream *stream,
if (!g_output_stream_set_pending (output_stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -560,11 +560,10 @@ g_input_stream_read_async (GInputStream *stream,
if (!g_input_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......@@ -685,11 +684,10 @@ g_input_stream_skip_async (GInputStream *stream,
if (!g_input_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......@@ -784,11 +782,10 @@ g_input_stream_close_async (GInputStream *stream,
if (!g_input_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -810,6 +810,7 @@ g_simple_async_result_set_error_va
g_simple_async_result_is_valid
g_simple_async_report_error_in_idle
g_simple_async_report_gerror_in_idle
g_simple_async_report_take_gerror_in_idle
#endif
#endif
......
......@@ -497,11 +497,10 @@ g_io_stream_close_async (GIOStream *stream,
if (!g_io_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -730,11 +730,10 @@ g_output_stream_write_async (GOutputStream *stream,
if (!g_output_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......@@ -853,11 +852,10 @@ g_output_stream_splice_async (GOutputStream *stream,
if (!g_output_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......@@ -936,11 +934,10 @@ g_output_stream_flush_async (GOutputStream *stream,
if (!g_output_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......@@ -1048,11 +1045,10 @@ g_output_stream_close_async (GOutputStream *stream,
if (!g_output_stream_set_pending (stream, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback,
user_data,
error);
g_error_free (error);
return;
}
......
......@@ -987,7 +987,7 @@ void
g_simple_async_report_gerror_in_idle (GObject *object,
GAsyncReadyCallback callback,
gpointer user_data,
GError *error)
const GError *error)
{
GSimpleAsyncResult *simple;
......@@ -1001,3 +1001,35 @@ g_simple_async_report_gerror_in_idle (GObject *object,
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}
/**
* g_simple_async_report_take_gerror_in_idle:
* @object: a #GObject.
* @callback: a #GAsyncReadyCallback.
* @user_data: user data passed to @callback.
* @error: the #GError to report
*
* Reports an error in an idle function. Similar to
* g_simple_async_report_gerror_in_idle(), but takes over the caller's
* ownership of @error, so the caller does not have to free it any more.
*
* Since: 2.28
**/
void
g_simple_async_report_take_gerror_in_idle (GObject *object,
GAsyncReadyCallback callback,
gpointer user_data,
GError *error)
{
GSimpleAsyncResult *simple;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (error != NULL);
simple = g_simple_async_result_new_take_error (object,
callback,
user_data,
error);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}
......@@ -122,7 +122,11 @@ void g_simple_async_report_error_in_idle (GObject *object,
void g_simple_async_report_gerror_in_idle (GObject *object,
GAsyncReadyCallback callback,
gpointer user_data,
GError *error);
const GError *error);
void g_simple_async_report_take_gerror_in_idle (GObject *object,
GAsyncReadyCallback callback,
gpointer user_data,
GError *error);
G_END_DECLS
......
......@@ -1279,9 +1279,8 @@ g_socket_client_connect_to_host_async (GSocketClient *client,
&error);
if (connectable == NULL)
{
g_simple_async_report_gerror_in_idle (G_OBJECT (client),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client),
callback, user_data, error);
g_error_free (error);
}
else
{
......@@ -1355,9 +1354,8 @@ g_socket_client_connect_to_uri_async (GSocketClient *client,
connectable = g_network_address_parse_uri (uri, default_port, &error);
if (connectable == NULL)
{
g_simple_async_report_gerror_in_idle (G_OBJECT (client),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (client),
callback, user_data, error);
g_error_free (error);
}
else
{
......
......@@ -332,10 +332,9 @@ g_socket_connection_close_async (GIOStream *stream,
if (class->close_fn &&
!class->close_fn (stream, cancellable, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (stream),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (stream),
callback, user_data,
error);
g_error_free (error);
return;
}
......
......@@ -747,10 +747,9 @@ g_socket_listener_accept_socket_async (GSocketListener *listener,
if (!check_listener (listener, &error))
{
g_simple_async_report_gerror_in_idle (G_OBJECT (listener),
g_simple_async_report_take_gerror_in_idle (G_OBJECT (listener),
callback, user_data,
error);
g_error_free (error);
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment