summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUmang Jain <mailumangjain@gmail.com>2017-12-08 11:20:06 +0530
committerDebarshi Ray <debarshir@gnome.org>2017-12-30 22:26:05 +0100
commitf725f97908f52a6cf46da7fa6066c90733008087 (patch)
tree9ec9f63c559ab107195db479b8d15a9a33a212eb
parentd0525fdc47012c608a85347db72a65951b584c51 (diff)
downloadgdk-pixbuf-f725f97908f52a6cf46da7fa6066c90733008087.tar.gz
gdk-pixbuf-io: Simplify code
https://bugzilla.gnome.org/show_bug.cgi?id=790584
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 3db328656..c4272a665 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -1542,7 +1542,7 @@ load_from_stream_async_cb (GObject *stream,
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
GError *error = NULL;
- GBytes *bytes;
+ GBytes *bytes = NULL;
loader = g_task_get_task_data (task);
@@ -1551,7 +1551,6 @@ load_from_stream_async_cb (GObject *stream,
if (bytes == NULL) {
gdk_pixbuf_loader_close (loader, NULL);
g_task_return_error (task, error);
- g_object_unref (task);
} else if (g_bytes_get_size (bytes) > 0) {
if (!gdk_pixbuf_loader_write (loader,
g_bytes_get_data (bytes, NULL),
@@ -1559,30 +1558,28 @@ load_from_stream_async_cb (GObject *stream,
&error)) {
gdk_pixbuf_loader_close (loader, NULL);
g_task_return_error (task, error);
- g_object_unref (task);
- g_bytes_unref (bytes);
- return;
+ goto out;
}
- g_bytes_unref (bytes);
g_input_stream_read_bytes_async (G_INPUT_STREAM (stream),
LOAD_BUFFER_SIZE,
G_PRIORITY_DEFAULT,
g_task_get_cancellable (task),
load_from_stream_async_cb,
- task);
+ g_object_ref (task));
+
} else {
- g_bytes_unref (bytes);
-
if (!gdk_pixbuf_loader_close (loader, &error)) {
g_task_return_error (task, error);
- g_object_unref (task);
- return;
+ goto out;
}
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
g_task_return_pointer (task, g_object_ref (pixbuf), g_object_unref);
- g_object_unref (task);
}
+
+out:
+ g_bytes_unref (bytes);
+ g_object_unref (task);
}