[rygel/rygel-0-24] server: Prevent crash on thumbnail



commit e853546d56f21d0ea9e8b55623cd316334f1f542
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 19 14:40:33 2015 +0200

    server: Prevent crash on thumbnail
    
    If the VisualItem does not have a mime type, the old code would add a "null"
    thumbnail to the list which would be dereferenced on serialisation.

 src/librygel-server/rygel-thumbnailer.vala |    6 +++---
 src/librygel-server/rygel-visual-item.vala |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/librygel-server/rygel-thumbnailer.vala b/src/librygel-server/rygel-thumbnailer.vala
index f502161..1b291ba 100644
--- a/src/librygel-server/rygel-thumbnailer.vala
+++ b/src/librygel-server/rygel-thumbnailer.vala
@@ -67,7 +67,7 @@ internal class Rygel.Thumbnailer : GLib.Object {
         return thumbnailer;
     }
 
-    public Thumbnail get_thumbnail (string uri, string mime_type) throws Error {
+    public Thumbnail get_thumbnail (string uri, string? mime_type) throws Error {
         var file = File.new_for_uri (uri);
         if (!file.is_native ()) {
             throw new ThumbnailerError.NO_THUMBNAIL
@@ -90,11 +90,11 @@ internal class Rygel.Thumbnailer : GLib.Object {
 
         // Send a request to create thumbnail if it does not exist, signal
         // that there's no thumbnail available now.
-        if (this.thumbler != null && path == null) {
+        if (this.thumbler != null && path == null && mime_type != null) {
             this.thumbler.queue_thumbnail_task (uri, mime_type);
 
             throw new ThumbnailerError.NO_THUMBNAIL
-                                        (_("No thumbnail available"));
+                                        (_("No thumbnail available. Generation requested."));
         }
 
         if (path == null) {
diff --git a/src/librygel-server/rygel-visual-item.vala b/src/librygel-server/rygel-visual-item.vala
index 82a792e..f57be4b 100644
--- a/src/librygel-server/rygel-visual-item.vala
+++ b/src/librygel-server/rygel-visual-item.vala
@@ -59,7 +59,7 @@ public interface Rygel.VisualItem : MediaItem {
         // Lets see if we can provide the thumbnails
         var thumbnailer = Thumbnailer.get_default ();
 
-        if (thumbnailer != null) {
+        if (thumbnailer != null && this.mime_type != null) {
             try {
                 var thumb = thumbnailer.get_thumbnail (uri, this.mime_type);
                 this.thumbnails.add (thumb);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]