Update of /cvsroot/gtkpod/libgpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv29672/src

Modified Files:
        itdb_artwork.c ithumb-writer.c 
Log Message:
        * 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.



Index: itdb_artwork.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb_artwork.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- itdb_artwork.c      23 Nov 2006 15:02:57 -0000      1.17
+++ itdb_artwork.c      26 Nov 2006 15:00:41 -0000      1.18
@@ -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 @@
                                         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

Index: ithumb-writer.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/ithumb-writer.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- ithumb-writer.c     23 Nov 2006 15:02:57 -0000      1.24
+++ ithumb-writer.c     26 Nov 2006 15:00:41 -0000      1.25
@@ -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 @@
                                 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 @@
 
     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 @@
        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 !! */


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to