summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorg Schuler <jcsjcs@users.sourceforge.net>2006-11-26 15:00:41 +0000
committerJorg Schuler <jcsjcs@users.sourceforge.net>2006-11-26 15:00:41 +0000
commitac01cffc7e943d67bea97520f23fb0556be26fcc (patch)
tree98abfbe91d8744e37bbe603e2cbc6ffdbe403c80
parentc4d8ab586052e4fe856fad2507e12ace01d2b302 (diff)
downloadlibgpod-ac01cffc7e943d67bea97520f23fb0556be26fcc.tar.gz
libgpod-ac01cffc7e943d67bea97520f23fb0556be26fcc.tar.xz
libgpod-ac01cffc7e943d67bea97520f23fb0556be26fcc.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
-rw-r--r--src/itdb_artwork.c7
-rw-r--r--src/ithumb-writer.c16
2 files changed, 15 insertions, 8 deletions
diff --git a/src/itdb_artwork.c b/src/itdb_artwork.c
index 4435a82..2defb4d 100644
--- a/src/itdb_artwork.c
+++ b/src/itdb_artwork.c
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-11-23 23:27:35 jcs>
+/* Time-stamp: <2006-11-26 23:31:45 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -662,12 +662,15 @@ itdb_thumb_get_gdk_pixbuf (Itdb_Device *device, Itdb_Thumb *thumb)
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);
}
if (!pixbuf)
+ {
return NULL;
+ }
/* !! cannot write directly to &thumb->width/height because
g_object_get() returns a gint, but thumb->width/height are
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 !! */