Commit 006cdac5 authored by Carlos Garnacho's avatar Carlos Garnacho

wayland: Use read_all() when reading wayland selections

Plain input stream read() calls don't provide hard guarantees about
the number of bytes read, but the async method callback sort of
relies on bytes being less than requested only when reaching the
end of the transmitted data. If that happens mid transfer, that
doesn't bode well.

This is actually the behavior of g_input_stream_read_all(), so
switch to using it.
parent 61bc1a7d
...@@ -689,9 +689,8 @@ wayland_data_read_cb (GObject *object, ...@@ -689,9 +689,8 @@ wayland_data_read_cb (GObject *object,
GError *error = NULL; GError *error = NULL;
gsize bytes_read; gsize bytes_read;
bytes_read = g_input_stream_read_finish (G_INPUT_STREAM (object), if (!g_input_stream_read_all_finish (G_INPUT_STREAM (object),
res, &error); res, &bytes_read, &error))
if (error)
{ {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
{ {
...@@ -762,10 +761,10 @@ wayland_selection_data_read (MetaSelectionBridge *selection) ...@@ -762,10 +761,10 @@ wayland_selection_data_read (MetaSelectionBridge *selection)
{ {
WaylandSelectionData *data = selection->wayland_selection; WaylandSelectionData *data = selection->wayland_selection;
g_input_stream_read_async (data->stream, data->buffer, g_input_stream_read_all_async (data->stream, data->buffer,
data->cancellable, data->cancellable,
wayland_data_read_cb, selection); wayland_data_read_cb, selection);
} }
static void static void
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