diff options
author | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2006-11-26 15:00:41 +0000 |
---|---|---|
committer | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2006-11-26 15:00:41 +0000 |
commit | 2a28a904b3804188497c78da40785901b5d8e089 (patch) | |
tree | 98abfbe91d8744e37bbe603e2cbc6ffdbe403c80 /src/ithumb-writer.c | |
parent | f08cacc8c0de00ede8dcaa3de5b0ecae37ebb173 (diff) | |
download | libgpod-tmz-2a28a904b3804188497c78da40785901b5d8e089.tar.gz libgpod-tmz-2a28a904b3804188497c78da40785901b5d8e089.tar.xz libgpod-tmz-2a28a904b3804188497c78da40785901b5d8e089.zip |
* src/ithumb-writer.c (ithumb_writer_write_thumbnail): handle
corrupted image data in a way that does not crash libgpod nor
causes the ArtworkDB or PhotoDB to be corrupted. Currently a
completely red pixmap is created as a substitute. Somewhat more
artistic than I am may want to create a "corrupted image data"
pixmap we can imbed into the code.
* src/itdb_artwork.c (itdb_thumb_get_gdk_pixbuf): fix failed
assertion when image data is illegal.
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1341 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src/ithumb-writer.c')
-rw-r--r-- | src/ithumb-writer.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c index f20546f..6de41b1 100644 --- a/src/ithumb-writer.c +++ b/src/ithumb-writer.c @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-11-23 23:45:01 jcs> +/* Time-stamp: <2006-11-26 23:30:08 jcs> * * Copyright (C) 2005 Christophe Fergeau * @@ -347,7 +347,8 @@ ithumb_writer_write_thumbnail (iThumbWriter *writer, NULL); gdk_pixbuf_loader_close (loader, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - g_object_ref (pixbuf); + if (pixbuf) + g_object_ref (pixbuf); g_object_unref (loader); g_free (thumb->image_data); @@ -357,7 +358,11 @@ ithumb_writer_write_thumbnail (iThumbWriter *writer, if (pixbuf == NULL) { - return FALSE; + /* This is quite bad... if we just return FALSE the ArtworkDB + gets messed up. For now let's insert a red thumbnail until + someone comes up with a "broken thumbnail" design */ + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); + gdk_pixbuf_fill (pixbuf, 0xff000000); } /* Rotate if necessary */ @@ -366,11 +371,10 @@ ithumb_writer_write_thumbnail (iThumbWriter *writer, GdkPixbuf *new_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, thumb->rotation); g_object_unref (pixbuf); pixbuf = new_pixbuf; + /* Clean up */ + thumb->rotation = 0; } - /* Clean up */ - thumb->rotation = 0; - /* !! cannot write directly to &thumb->width/height because g_object_get() returns a gint, but thumb->width/height are gint16 !! */ |