[gdk-pixbuf] gdk-pixbuf-io: Simplify code
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] gdk-pixbuf-io: Simplify code
- Date: Sat, 30 Dec 2017 21:27:23 +0000 (UTC)
commit f725f97908f52a6cf46da7fa6066c90733008087
Author: Umang Jain <mailumangjain gmail com>
Date: Fri Dec 8 11:20:06 2017 +0530
gdk-pixbuf-io: Simplify code
https://bugzilla.gnome.org/show_bug.cgi?id=790584
gdk-pixbuf/gdk-pixbuf-io.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 3db3286..c4272a6 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]