Bug 714983 - avoid exceptions in file-utils.js when dismissing file picker dialog. r=myk
authoraceman <acelists@atlas.sk>
Mon, 09 Jan 2012 08:46:43 +0000
changeset 10376 70fa39beb291c7e8db1ffb1d8d829bc525f9304c
parent 10375 26a499076c7ed60f4d115c3c7fa0caf38fd02636
child 10377 0eef83152b2d320d504b030f46756e065d543f4e
push id402
push userbugzilla@standard8.plus.com
push dateTue, 13 Mar 2012 21:17:18 +0000
treeherdercomm-beta@d080a8ebf16a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk
bugs714983
Bug 714983 - avoid exceptions in file-utils.js when dismissing file picker dialog. r=myk
mailnews/extensions/newsblog/content/file-utils.js
--- a/mailnews/extensions/newsblog/content/file-utils.js
+++ b/mailnews/extensions/newsblog/content/file-utils.js
@@ -170,45 +170,47 @@ function futils_nosepicker(initialPath, 
  
     return picker;
 }
 
 function pickSaveAs (title, typeList, defaultFile, defaultDir)
 {
     if (!defaultDir && "lastSaveAsDir" in futils)
         defaultDir = futils.lastSaveAsDir;
-    
-    var picker = futils.getPicker (defaultDir, typeList, 
+
+    var picker = futils.getPicker (defaultDir, typeList,
                                    {defaultString: defaultFile});
     picker.init (window, title ? title : futils.MSG_SAVE_AS,
                  Components.interfaces.nsIFilePicker.modeSave);
 
     var rv = picker.show();
-    
-    if (rv != PICK_CANCEL)
-        futils.lastSaveAsDir = picker.file.parent;
 
+    if (rv == PICK_CANCEL)
+        return {reason: rv};
+
+    futils.lastSaveAsDir = picker.file.parent;
     return {reason: rv, file: picker.file, picker: picker};
 }
 
 function pickOpen (title, typeList, defaultFile, defaultDir)
 {
     if (!defaultDir && "lastOpenDir" in futils)
         defaultDir = futils.lastOpenDir;
-    
-    var picker = futils.getPicker (defaultDir, typeList, 
+
+    var picker = futils.getPicker (defaultDir, typeList,
                                    {defaultString: defaultFile});
     picker.init (window, title ? title : futils.MSG_OPEN,
                  Components.interfaces.nsIFilePicker.modeOpen);
 
     var rv = picker.show();
-    
-    if (rv != PICK_CANCEL)
-        futils.lastOpenDir = picker.file.parent;
 
+    if (rv == PICK_CANCEL)
+        return {reason: rv};
+
+    futils.lastOpenDir = picker.file.parent;
     return {reason: rv, file: picker.file, picker: picker};
 }
 
 function fopen (path, mode, perms, tmp)
 {
     return new LocalFile(path, mode, perms, tmp);
 }