[f-spot/stable-0.8] Don't crash in InfoBox if querying file info throws an Exception and/or metadata is null



commit d528d264b4703f1704dea24b0f6526d2658b20bc
Author: Paul Wellner Bou <paul purecodes org>
Date:   Thu Dec 16 09:17:30 2010 +0100

    Don't crash in InfoBox if querying file info throws an Exception and/or metadata is null
    
    https://bugzilla.gnome.org/show_bug.cgi?id=637283

 src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
index 52d5769..31db574 100644
--- a/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
+++ b/src/Core/FSpot.Utils/FSpot.Utils/Metadata.cs
@@ -10,9 +10,15 @@ namespace FSpot.Utils
         public static TagLib.Image.File Parse (SafeUri uri)
         {
             // Detect mime-type
-            var gfile = FileFactory.NewForUri (uri);
-            var info = gfile.QueryInfo ("standard::content-type", FileQueryInfoFlags.None, null);
-            var mime = info.ContentType;
+            string mime;
+            try {
+                var gfile = FileFactory.NewForUri (uri);
+                var info = gfile.QueryInfo ("standard::content-type", FileQueryInfoFlags.None, null);
+                mime = info.ContentType;
+            } catch (Exception e) {
+                Hyena.Log.DebugException (e);
+                return null;
+            }
 
             if (mime.StartsWith ("application/x-extension-")) {
                 // Works around broken metadata detection - https://bugzilla.gnome.org/show_bug.cgi?id=624781



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