Bug 865803 - allow not setting defaultDirectory (nullcheck before converting to URL), r=joshmoz
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 26 Apr 2013 19:46:32 +0200
changeset 141090 dbe8ad85f3596ceeb9b52fc44ed8085eb70e47d6
parent 141089 3b7a2cbccaaa848eb10b2f9b50f89b5a322ba379
child 141091 8f5c7725deb9935fca434d1ce8edb8edd0d8ee73
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoshmoz
bugs865803
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 865803 - allow not setting defaultDirectory (nullcheck before converting to URL), r=joshmoz
widget/cocoa/nsFilePicker.mm
--- a/widget/cocoa/nsFilePicker.mm
+++ b/widget/cocoa/nsFilePicker.mm
@@ -315,17 +315,19 @@ nsFilePicker::GetLocalFiles(const nsStri
   if (!theDir) {
     if (filters && [filters count] == 1 &&
         [(NSString *)[filters objectAtIndex:0] isEqualToString:@"app"])
       theDir = @"/Applications/";
     else
       theDir = @"";
   }
 
-  [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  if (theDir) {
+    [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  }
 
   int result;
   nsCocoaUtils::PrepareForNativeAppModalDialog();
   if (mFilters.Length() > 1) {
     // [NSURL initWithString:] (below) throws an exception if URLString is nil.
 
     NSPopUpButtonObserver* observer = [[NSPopUpButtonObserver alloc] init];
 
@@ -406,17 +408,19 @@ nsFilePicker::GetLocalFolder(const nsStr
   [thePanel setResolvesAliases:YES];          //this is default - probably doesn't need to be set
   [thePanel setCanCreateDirectories:YES];
   
   // packages != folders
   [thePanel setTreatsFilePackagesAsDirectories:NO];
 
   // set up default directory
   NSString *theDir = PanelDefaultDirectory();
-  [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  if (theDir) {
+    [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  }
   nsCocoaUtils::PrepareForNativeAppModalDialog();
   int result = [thePanel runModal];
   nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
 
   if (result == NSFileHandlingPanelCancelButton)
     return retVal;
 
   // get the path for the folder (we allow just 1, so that's all we get)
@@ -455,17 +459,19 @@ nsFilePicker::PutLocalFile(const nsStrin
   NSView* accessoryView = GetAccessoryView();
   [thePanel setAccessoryView:accessoryView];
 
   // set up default file name
   NSString* defaultFilename = [NSString stringWithCharacters:(const unichar*)inDefaultName.get() length:inDefaultName.Length()];
 
   // set up default directory
   NSString *theDir = PanelDefaultDirectory();
-  [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  if (theDir) {
+    [thePanel setDirectoryURL:[[NSURL alloc] initFileURLWithPath:theDir isDirectory:YES]];
+  }
 
   // load the panel
   nsCocoaUtils::PrepareForNativeAppModalDialog();
   [thePanel setNameFieldStringValue:defaultFilename];
   int result = [thePanel runModal];
   nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
   if (result == NSFileHandlingPanelCancelButton)
     return retVal;