mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 21:46:14 +01:00
Add g_simple_async_report_take_gerror_in_idle
... and use it where appropriate. Saves an extra GError copy. Bug #633686.
This commit is contained in:
parent
9e0c07870a
commit
ba45e36932
@ -1172,6 +1172,7 @@ g_simple_async_result_set_error
|
|||||||
g_simple_async_result_set_error_va
|
g_simple_async_result_set_error_va
|
||||||
g_simple_async_report_error_in_idle
|
g_simple_async_report_error_in_idle
|
||||||
g_simple_async_report_gerror_in_idle
|
g_simple_async_report_gerror_in_idle
|
||||||
|
g_simple_async_report_take_gerror_in_idle
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GSimpleAsyncResultClass
|
GSimpleAsyncResultClass
|
||||||
G_SIMPLE_ASYNC_RESULT
|
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))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +215,10 @@ g_file_input_stream_query_info_async (GFileInputStream *stream,
|
|||||||
|
|
||||||
if (!g_input_stream_set_pending (input_stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,11 +227,10 @@ g_file_io_stream_query_info_async (GFileIOStream *stream,
|
|||||||
|
|
||||||
if (!g_io_stream_set_pending (io_stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,11 +225,10 @@ g_file_output_stream_query_info_async (GFileOutputStream *stream,
|
|||||||
|
|
||||||
if (!g_output_stream_set_pending (output_stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,11 +560,10 @@ g_input_stream_read_async (GInputStream *stream,
|
|||||||
|
|
||||||
if (!g_input_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,11 +684,10 @@ g_input_stream_skip_async (GInputStream *stream,
|
|||||||
|
|
||||||
if (!g_input_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,11 +782,10 @@ g_input_stream_close_async (GInputStream *stream,
|
|||||||
|
|
||||||
if (!g_input_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,6 +810,7 @@ g_simple_async_result_set_error_va
|
|||||||
g_simple_async_result_is_valid
|
g_simple_async_result_is_valid
|
||||||
g_simple_async_report_error_in_idle
|
g_simple_async_report_error_in_idle
|
||||||
g_simple_async_report_gerror_in_idle
|
g_simple_async_report_gerror_in_idle
|
||||||
|
g_simple_async_report_take_gerror_in_idle
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -497,11 +497,10 @@ g_io_stream_close_async (GIOStream *stream,
|
|||||||
|
|
||||||
if (!g_io_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,11 +730,10 @@ g_output_stream_write_async (GOutputStream *stream,
|
|||||||
|
|
||||||
if (!g_output_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,11 +852,10 @@ g_output_stream_splice_async (GOutputStream *stream,
|
|||||||
|
|
||||||
if (!g_output_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -936,11 +934,10 @@ g_output_stream_flush_async (GOutputStream *stream,
|
|||||||
|
|
||||||
if (!g_output_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,11 +1045,10 @@ g_output_stream_close_async (GOutputStream *stream,
|
|||||||
|
|
||||||
if (!g_output_stream_set_pending (stream, &error))
|
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,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@ void
|
|||||||
g_simple_async_report_gerror_in_idle (GObject *object,
|
g_simple_async_report_gerror_in_idle (GObject *object,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError *error)
|
const GError *error)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *simple;
|
GSimpleAsyncResult *simple;
|
||||||
|
|
||||||
@ -1001,3 +1001,35 @@ g_simple_async_report_gerror_in_idle (GObject *object,
|
|||||||
g_simple_async_result_complete_in_idle (simple);
|
g_simple_async_result_complete_in_idle (simple);
|
||||||
g_object_unref (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);
|
||||||
|
}
|
||||||
|
@ -120,6 +120,10 @@ void g_simple_async_report_error_in_idle (GObject *object,
|
|||||||
const char *format,
|
const char *format,
|
||||||
...);
|
...);
|
||||||
void g_simple_async_report_gerror_in_idle (GObject *object,
|
void g_simple_async_report_gerror_in_idle (GObject *object,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
const GError *error);
|
||||||
|
void g_simple_async_report_take_gerror_in_idle (GObject *object,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GError *error);
|
GError *error);
|
||||||
|
@ -1279,9 +1279,8 @@ g_socket_client_connect_to_host_async (GSocketClient *client,
|
|||||||
&error);
|
&error);
|
||||||
if (connectable == NULL)
|
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);
|
callback, user_data, error);
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1355,9 +1354,8 @@ g_socket_client_connect_to_uri_async (GSocketClient *client,
|
|||||||
connectable = g_network_address_parse_uri (uri, default_port, &error);
|
connectable = g_network_address_parse_uri (uri, default_port, &error);
|
||||||
if (connectable == NULL)
|
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);
|
callback, user_data, error);
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -332,10 +332,9 @@ g_socket_connection_close_async (GIOStream *stream,
|
|||||||
if (class->close_fn &&
|
if (class->close_fn &&
|
||||||
!class->close_fn (stream, cancellable, &error))
|
!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,
|
callback, user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,10 +747,9 @@ g_socket_listener_accept_socket_async (GSocketListener *listener,
|
|||||||
|
|
||||||
if (!check_listener (listener, &error))
|
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,
|
callback, user_data,
|
||||||
error);
|
error);
|
||||||
g_error_free (error);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user