diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Native_File_Chooser_MAC.mm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Fl_Native_File_Chooser_MAC.mm b/src/Fl_Native_File_Chooser_MAC.mm index bb09a1789..fa69d9ff2 100644 --- a/src/Fl_Native_File_Chooser_MAC.mm +++ b/src/Fl_Native_File_Chooser_MAC.mm @@ -602,8 +602,22 @@ int Fl_Quartz_Native_File_Chooser_Driver::runmodal() } if (_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory]; if (fl_mac_os_version >= 100600) { - if (dir) [(NSSavePanel*)_panel performSelector:@selector(setDirectoryURL:) withObject:[NSURL fileURLWithPath:dir]]; - if (fname) [(NSSavePanel*)_panel performSelector:@selector(setNameFieldStringValue:) withObject:fname]; + if (dir && fname) { + // STR #3406: If both dir + fname specified, combine and pass to setDirectoryURL + NSString *path = [[NSString alloc] initWithFormat:@"%@/%@", dir, fname]; // dir+fname -> path + // See if full path to file exists + // If dir exists but fname doesn't, avoid using setDirectoryURL, + // otherwise NSSavePanel falls back to showing user's Documents dir. + // + if ( [[NSFileManager defaultManager] fileExistsAtPath:path] ) { + // Set only if full path exists + [(NSSavePanel*)_panel performSelector:@selector(setDirectoryURL:) withObject:[NSURL fileURLWithPath:path]]; + } else { // didn't setDirectoryURL to full path? Set dir + fname separately.. + if (dir) [(NSSavePanel*)_panel performSelector:@selector(setDirectoryURL:) withObject:[NSURL fileURLWithPath:dir]]; + if (fname) [(NSSavePanel*)_panel performSelector:@selector(setNameFieldStringValue:) withObject:fname]; + } + [path release]; + } retval = [(NSSavePanel*)_panel runModal]; } else { |
