Tk Source Code

View Ticket
Login
Ticket UUID: 56a1823c73d45b29c2b7e7fdde85012a1495b17
Title: In Aqua, tk_GetOpenFile causes toplevels to open off screen
Type: Bug Version: 8.6.9
Submitter: marc_culler Created on: 2019-02-17 04:10:32
Subsystem: 37. [tk_get*File] Assigned To: marc_culler
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2019-02-23 02:16:27
Resolution: Fixed Closed By: marc_culler
    Closed on: 2019-02-23 02:16:27
Description:

In Aqua, running this script in Wish causes a toplevel to appear containing the text "this is a filename":

wm iconify .
set filename "this is a filename"
toplevel .t -width 80 -height 100 
text .t.text
pack .t.text
.t.text insert end $filename

Running the following script opens a file dialog, but when the dialog is dismissed no toplevel appears. Clicking the feather icon in the dock makes a toplevel appear, containing the pathname of the selected file:

wm iconify .
set filename [tk_getOpenFile]
toplevel .t -width 80 -height 100 
text .t.text
pack .t.text
.t.text insert end $filename

Adding these three lines makes an empty toplevel appear:

update
wm iconify .t
wm deiconify .t

Adding an additional focus command makes the pathname appear in the window:

focus .t.text

None of those additional lines should be necessary. It seems that when the filedialog is closed the NSApplication is left for some time in a state where any new NSWindows that are created are opened off screen. Testing indicates that [NSWindow isVisible] returns YES even though the window is not visible.

User Comments: marc_culler (claiming to be Marc Culler) added on 2019-02-23 02:16:27:
Thanks to Kevin Walzer for reviewing these changes!  We agree that the
bugs are fixed and neither of us were able to produce any crashes or
regressions related to the fix.  Also, there are no changes in the regression
test results. So I will merge the fix and close this ticket.

marc_culler (claiming to be Marc Culler) added on 2019-02-18 18:53:49:

I also noticed that if the root window is withdrawn rather than iconified a dead window with black background appears on the screen after the root disappears.

Both of these problems are fixed in check-in 60edb6d4 by processing all pending events in XMapWindow and in the NSApplication method applicationDidFinishLaunching.