[recipes/image-download: 4/13] Return NULL if pixbuf loading fails
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/image-download: 4/13] Return NULL if pixbuf loading fails
- Date: Sun, 2 Apr 2017 17:06:54 +0000 (UTC)
commit cfc52b2a2a76728441b17d971212f6ada375bbe4
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 09138a6..f2056e3 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -51,15 +51,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);
@@ -89,13 +87,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]