[pdfmod] Avoid XDG-related crash in file chooser (bgo#619073)



commit 1bf89353c53ee111c0088462557e2cc693dcdbbb
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed May 19 10:40:25 2010 -0700

    Avoid XDG-related crash in file chooser (bgo#619073)

 src/PdfMod/Gui/Client.cs |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/PdfMod/Gui/Client.cs b/src/PdfMod/Gui/Client.cs
index dc0e21f..81e45f3 100644
--- a/src/PdfMod/Gui/Client.cs
+++ b/src/PdfMod/Gui/Client.cs
@@ -377,14 +377,23 @@ namespace PdfMod.Gui
             chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("PDF Documents"), new string [] {"pdf"}));
             chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("All Files"), new string [] {"*"}));
 
-            var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select (s =>
-                XdgBaseDirectorySpec.GetXdgDirectoryUnderHome (String.Format ("XDG_{0}_DIR", s), null)
-            ).Where (d => d != null).ToArray ();
+            var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select (s => GetXdgDir (s))
+                                                                .Where (d => d != null)
+                                                                .ToArray ();
             Hyena.Gui.GtkUtilities.SetChooserShortcuts (chooser, dirs);
 
             return chooser;
         }
 
+        private string GetXdgDir (string type)
+        {
+            try {
+                return XdgBaseDirectorySpec.GetXdgDirectoryUnderHome (String.Format ("XDG_{0}_DIR", type), null);
+            } catch {
+                return null;
+            }
+        }
+
         static void OnLogNotify (LogNotifyArgs args)
         {
             ThreadAssist.ProxyToMain (delegate {



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