[recipes/image-download: 4/10] Return NULL if pixbuf loading fails
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/image-download: 4/10] Return NULL if pixbuf loading fails
- Date: Mon, 6 Mar 2017 00:34:01 +0000 (UTC)
commit 7afbb53a8c0465bc1f40d65e3b07b23a844b19f7
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 2 23:10:22 2017 -0500
Return NULL if pixbuf loading fails
We want to use these functions to check if an image file exists,
so we need them to quietly return NULL.
src/gr-utils.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 3d05ded..71dfa95 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -52,15 +52,13 @@ load_pixbuf_fit_size (const char *path,
GdkPixbuf *pixbuf;
int dest_x, dest_y, dest_width, dest_height;
+ original = gdk_pixbuf_new_from_file_at_size (path, width, height, NULL);
+ if (!original)
+ return NULL;
+
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
gdk_pixbuf_fill (pixbuf, 0x00000000);
- original = gdk_pixbuf_new_from_file_at_size (path, width, height, NULL);
- if (!original) {
- g_warning ("Failed to load image %s", path);
- return pixbuf;
- }
-
if (pad) {
dest_width = gdk_pixbuf_get_width (original);
dest_height = gdk_pixbuf_get_height (original);
@@ -90,13 +88,8 @@ load_pixbuf_fill_size (const char *path,
int x, y;
original = gdk_pixbuf_new_from_file_at_scale (path, -1, height, TRUE, NULL);
- if (!original) {
- GdkPixbuf *pixbuf;
- g_warning ("Failed to load image %s", path);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- gdk_pixbuf_fill (pixbuf, 0x00000000);
- return pixbuf;
- }
+ if (!original)
+ return NULL;
if (gdk_pixbuf_get_width (original) < width) {
g_autoptr(GdkPixbuf) pb1 = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]