mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 09:58:54 +02:00
GMemoryInputStream/GMemoryOutputStream: fix bug in previous commit
A g_input_stream_read_async() implementation can't call g_input_stream_read() on itself directly because it will fail because the pending flag is already set. So fix that by invoking the vmethod directly rather than calling the wrapper. Likewise with GMemoryOutputStream. Add a test to gio/tests/memory-input-stream.c to catch read_async failures in the future.
This commit is contained in:
@@ -345,14 +345,22 @@ g_memory_input_stream_read_async (GInputStream *stream,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *simple;
|
||||
GError *error = NULL;
|
||||
gssize nread;
|
||||
|
||||
nread = g_input_stream_read (stream, buffer, count, cancellable, NULL);
|
||||
nread = G_INPUT_STREAM_GET_CLASS (stream)->read_fn (stream,
|
||||
buffer,
|
||||
count,
|
||||
cancellable,
|
||||
&error);
|
||||
simple = g_simple_async_result_new (G_OBJECT (stream),
|
||||
callback,
|
||||
user_data,
|
||||
g_memory_input_stream_read_async);
|
||||
g_simple_async_result_set_op_res_gssize (simple, nread);
|
||||
if (error)
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
else
|
||||
g_simple_async_result_set_op_res_gssize (simple, nread);
|
||||
g_simple_async_result_complete_in_idle (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
Reference in New Issue
Block a user