Tk Source Code

View Ticket
Login
Ticket UUID: 9eab54121318897339984e81b4f288c11886e5e6
Title: tk_getSaveFile - Parameter initialdir has side effects on macOS
Type: Bug Version: 8.6.6
Submitter: anonymous Created on: 2017-06-03 21:15:01
Subsystem: 83. Mac OS X Build Assigned To: kevin_walzer
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2017-08-03 06:49:51
Resolution: Accepted Closed By: anonymous
    Closed on: 2017-08-03 06:49:51
Description:
When I call tk_getSaveFile the second time in my application, the selected filename is appended twice to the path, e.g. /dir1/dir2/dir3/file.txt/file.txt
If I omit the parameter initialdir, the problem is gone. The parameter values are the same in both calls.
User Comments: anonymous (claiming to be auriocus) added on 2017-08-03 06:49:51:
It turns out that the open and save panel behave differently with respect to the preselected file. The original method (misusing setDirectory) was working for the open panel, whereas the save panel requires the new method (setNameField). The attached patch hopefully finally fixes the issue.

In addition, the appearance of the title message was improved, hopefully, for the last time. An OSX save panel does show the title message, if it has no -parent, whereas an open panel never displays the title. The title is prepended to the -message in these cases.

The filebox test suite now displays 7 failures, out of which 3 are related to error messages, two to OSX always appending the extension and 1 to the typevariable being unset, if no format is chosen (debatable)

kevin_walzer added on 2017-06-05 01:56:40:
The patch fixes the problem. Thanks to Christian Gollwitzer for patch and to Torsten for the bug report.

anonymous added on 2017-06-04 17:02:22:

Actually, it is more complicated than that, due to differences in the API of the NSSave and NSOpen panels (despite that NSOpen is derived from NSSave) and differences between OSX versions. Some details here:

https://stackoverflow.com/questions/8278490/nsopenpanel-nssavepanel-how-can-i-preselect-a-file-before-the-dialog-opens

https://stackoverflow.com/questions/18903904/how-do-you-preselect-a-file-in-the-nsopenpanel-dialog

I'll try to find a way which works on th emost recent OSX and is acceptable on older versions


anonymous added on 2017-06-03 22:16:30:
The code was misusing the directory field of the file dialog panel for both directory and file name, in an attempt to work around an API change from 10.6. Additionally, the -initialdir was ignored under some circumstances. 
The attached patch fixes the issue.

Attachments: