~ubuntu-branches/ubuntu/maverick/pdfmod/maverick-updates

« back to all changes in this revision

Viewing changes to debian/patches/0004-Avoid_XDG-related_crash_in_file_chooser.patch

  • Committer: Bazaar Package Importer
  • Author(s): Marcel Stimberg
  • Date: 2011-02-22 10:31:31 UTC
  • Revision ID: james.westby@ubuntu.com-20110222103131-vql9bwibcd5x4lq9
Tags: 0.8.3-1ubuntu0.1
debian/patches/0004-Avoid_XDG-related_crash_in_file_chooser.patch:
Backported upstream commit 1bf89353c53ee111c0088462557e2cc693dcdbbb
Avoid crash when XDG_DOCUMENTS_DIR or XDG_DOWNLOADS_DIR is not set 
(LP: #645137)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: pdfmod/src/PdfMod/Gui/Client.cs
 
2
===================================================================
 
3
--- pdfmod.orig/src/PdfMod/Gui/Client.cs        2011-02-13 12:40:55.426117998 +0100
 
4
+++ pdfmod/src/PdfMod/Gui/Client.cs     2011-02-13 12:41:09.316117998 +0100
 
5
@@ -377,14 +377,23 @@
 
6
             chooser.AddFilter (GtkUtilities.GetFileFilter ("PDF Documents", new string [] {"pdf"}));
 
7
             chooser.AddFilter (GtkUtilities.GetFileFilter (Catalog.GetString ("All Files"), new string [] {"*"}));
 
8
 
 
9
-            var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select (s =>
 
10
-                XdgBaseDirectorySpec.GetXdgDirectoryUnderHome (String.Format ("XDG_{0}_DIR", s), null)
 
11
-            ).Where (d => d != null).ToArray ();
 
12
+            var dirs = new string [] { "DOWNLOAD", "DOCUMENTS" }.Select (s => GetXdgDir (s))
 
13
+                                                                .Where (d => d != null)
 
14
+                                                                .ToArray ();
 
15
             Hyena.Gui.GtkUtilities.SetChooserShortcuts (chooser, dirs);
 
16
 
 
17
             return chooser;
 
18
         }
 
19
 
 
20
+        private string GetXdgDir (string type)
 
21
+        {
 
22
+            try {
 
23
+                return XdgBaseDirectorySpec.GetXdgDirectoryUnderHome (String.Format ("XDG_{0}_DIR", type), null);
 
24
+            } catch {
 
25
+                return null;
 
26
+            }
 
27
+        }
 
28
+
 
29
         static void OnLogNotify (LogNotifyArgs args)
 
30
         {
 
31
             ThreadAssist.ProxyToMain (delegate {