diff options
author | Bastien Nocera <hadess@hadess.net> | 2016-12-12 17:20:27 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2016-12-12 17:58:32 +0100 |
commit | ca523901a4dd7c4e503d857e83e7a0375d632f2a (patch) | |
tree | 03d004b5045c550f0120be02662a2d45bfa33e32 | |
parent | de8b5678291eb27a9370631c6dd3d15eded6bdfc (diff) | |
download | gdk-pixbuf-ca523901a4dd7c4e503d857e83e7a0375d632f2a.tar.gz |
thumbnailer: Avoid runtime warnings when file_to_pixbuf() fails
By updating the thumbnailer skeleton.
-rw-r--r-- | 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 6224bec28..812b58441 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); |