[gdk-pixbuf] thumbnailer: Avoid runtime warnings when file_to_pixbuf() fails
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] thumbnailer: Avoid runtime warnings when file_to_pixbuf() fails
- Date: Mon, 12 Dec 2016 16:59:21 +0000 (UTC)
commit ca523901a4dd7c4e503d857e83e7a0375d632f2a
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 12 17:20:27 2016 +0100
thumbnailer: Avoid runtime warnings when file_to_pixbuf() fails
By updating the thumbnailer skeleton.
thumbnailer/gnome-thumbnailer-skeleton.c | 41 ++++++++++++++++--------------
1 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/thumbnailer/gnome-thumbnailer-skeleton.c b/thumbnailer/gnome-thumbnailer-skeleton.c
index 6224bec..812b584 100644
--- a/thumbnailer/gnome-thumbnailer-skeleton.c
+++ b/thumbnailer/gnome-thumbnailer-skeleton.c
@@ -225,7 +225,7 @@ int main (int argc, char **argv)
const char *output;
#ifdef THUMBNAILER_RETURNS_PIXBUF
- int width, height;
+ /* Nothing */
#elif THUMBNAILER_RETURNS_DATA
char *data = NULL;
gsize length;
@@ -270,24 +270,27 @@ int main (int argc, char **argv)
#ifdef THUMBNAILER_RETURNS_PIXBUF
pixbuf = file_to_pixbuf (input_filename, output_size, &error);
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
-
- /* Handle naive thumbnailers that don't resize */
- if (output_size != 0 &&
- (height > output_size || width > output_size)) {
- GdkPixbuf *scaled;
- double scale;
-
- scale = (double)output_size / MAX (width, height);
-
- scaled = gnome_desktop_thumbnail_scale_down_pixbuf (pixbuf,
- floor (width * scale + 0.5),
- floor (height * scale + 0.5));
- gdk_pixbuf_copy_options (pixbuf, scaled);
- g_object_unref (pixbuf);
- pixbuf = scaled;
+ if (pixbuf != NULL) {
+ int width, height;
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+
+ /* Handle naive thumbnailers that don't resize */
+ if (output_size != 0 &&
+ (height > output_size || width > output_size)) {
+ GdkPixbuf *scaled;
+ double scale;
+
+ scale = (double)output_size / MAX (width, height);
+
+ scaled = gnome_desktop_thumbnail_scale_down_pixbuf (pixbuf,
+ floor (width * scale + 0.5),
+ floor (height * scale + 0.5));
+ gdk_pixbuf_copy_options (pixbuf, scaled);
+ g_object_unref (pixbuf);
+ pixbuf = scaled;
+ }
}
#elif THUMBNAILER_RETURNS_DATA
data = file_to_data (input_filename, &length, &error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]