From a0daebbb60e5ad0edab9266d83ebc91d963ccd07 Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Mon, 13 May 2019 10:38:01 +0200 Subject: [PATCH] removed recursion, sync load - still leaking --- src/xfce-backdrop.c | 57 +++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/xfce-backdrop.c b/src/xfce-backdrop.c index c85ddcf5..5c71892c 100644 --- a/src/xfce-backdrop.c +++ b/src/xfce-backdrop.c @@ -82,10 +82,6 @@ static void xfce_backdrop_file_ready_cb(GObject *source_object, GAsyncResult *res, gpointer user_data); -static void xfce_backdrop_file_input_stream_ready_cb(GObject *source_object, - GAsyncResult *res, - gpointer user_data); - static void xfce_backdrop_image_data_release(XfceBackdropImageData *image_data); gchar *xfce_backdrop_choose_next (XfceBackdrop *backdrop); @@ -1990,46 +1986,45 @@ xfce_backdrop_file_ready_cb(GObject *source_object, return; } - g_input_stream_read_async(G_INPUT_STREAM(input_stream), - image_data->image_buffer, - XFCE_BACKDROP_BUFFER_SIZE, - G_PRIORITY_LOW, - image_data->cancellable, - xfce_backdrop_file_input_stream_ready_cb, - image_data); -} - -static void -xfce_backdrop_file_input_stream_ready_cb(GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GInputStream *stream = G_INPUT_STREAM(source_object); - XfceBackdropImageData *image_data = user_data; - gssize bytes = g_input_stream_read_finish(stream, res, NULL); + while (TRUE) + { + gssize bytes = g_input_stream_read (G_INPUT_STREAM(input_stream), + image_data->image_buffer, + XFCE_BACKDROP_BUFFER_SIZE, + image_data->cancellable, + NULL); if(bytes == -1 || bytes == 0) { + printf("xfce_backdrop_file_input_stream_ready_cb close1\n"); /* If there was an error reading the stream or it completed, clean * up and close the pixbuf loader (which will handle both conditions) */ - g_input_stream_close(stream, image_data->cancellable, NULL); + g_input_stream_close(G_INPUT_STREAM(input_stream), image_data->cancellable, NULL); + //g_input_stream_close_async (stream, G_PRIORITY_LOW, image_data->cancellable, NULL, NULL); + printf("xfce_backdrop_file_input_stream_ready_cb close2\n"); g_object_unref(source_object); - + printf("xfce_backdrop_file_input_stream_ready_cb close3\n"); gdk_pixbuf_loader_close(image_data->loader, NULL); + printf("xfce_backdrop_file_input_stream_ready_cb close4\n"); return; } if(gdk_pixbuf_loader_write(image_data->loader, image_data->image_buffer, bytes, NULL)) { - g_input_stream_read_async(stream, - image_data->image_buffer, - XFCE_BACKDROP_BUFFER_SIZE, - G_PRIORITY_LOW, - image_data->cancellable, - xfce_backdrop_file_input_stream_ready_cb, - image_data); + printf("g_input_stream_read_async\n"); } else { + printf("g_input_stream_read_async close (else)\n"); /* If we got here, the loader will be closed, and will not accept * further writes. */ - g_input_stream_close(stream, image_data->cancellable, NULL); + g_input_stream_close(G_INPUT_STREAM(input_stream), image_data->cancellable, NULL); g_object_unref(source_object); } + + } + +// g_input_stream_read_async(G_INPUT_STREAM(input_stream), +// image_data->image_buffer, +// XFCE_BACKDROP_BUFFER_SIZE, +// G_PRIORITY_LOW, +// image_data->cancellable, +// xfce_backdrop_file_input_stream_ready_cb, +// image_data); } -- 2.20.1