| Ticket UUID: | e2cec2fa41da23504bc80f82599101c29c850d55 | |||
| Title: | tk_messageBox, multiple displays, vwait never returns | |||
| Type: | Bug | Version: | Tk 8.7, X11 | |
| Submitter: | kjnash | Created on: | 2023-08-21 23:27:09 | |
| Subsystem: | 38. [tk_messageBox] | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2023-12-16 08:43:48 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2023-12-16 08:43:48 | |||
| Description: |
I don't understand this bug. The example script creates toplevel windows on two displays, and then uses vwait to wait on a button in a simple dialog. The first use of a ::tk::Priv array element for vwait on a display that does not hold the root window always fails. The vwait command never returns. After the dialog with vwait is destroyed, new dialogs of the same kind work correctly. Sometimes the dialog on the display with the root window fails in the same way, but usually it does not. If only one display is used, the bug does not occur. In the example the main display is ":0.0" and a VNC display is ":1.0". The important factor is not whether the dialog uses the "main" display, but whether it uses the display that has the root window. If wish is launched on :1.0, the dialog problem occurs on :0.0, and vice versa. ::tk::Priv is a private array used by Tk. The reason for using it here is that tk::MessageBox0 is a reduced form of the library command tk::MessageBox which has the same bug but a lot more complexity. The obvious workaround is simply to vwait on a different variable - but I wondered if anyone understands what is going on. | |||
| User Comments: |
fvogel added on 2023-12-16 08:43:48:
Keith, Your changes for fixing this ticket were committed in trunk (at this time: 8.7) only, see [e984cb7a16], later merged with a bigger bunch of changes in [003f186c1c]. It turns out that others have been trying to address a problem that is close or identical to this one, see [c23f79ef96]. They addressed it in a branch off core-8-6-branch. Now when I try to merge the [66e803e4] state of bugfix branch bug-c23f79ef96 into core-8-6-branch, everything is fine. But when I try then to merge into trunk there are non-trivial conflicts between your approach in the present ticket and the fixes made in [66e803e4]. My approach to resolve this would be:
This way I believe we would have no conflict, AND both tickets would be fixed. What do you think? Could you confirm the fixes for [c23f79ef96] also fixes the present ticket, and advise regarding which commit we should backout to get a clean merge? Thanks for your feedback. kjnash added on 2023-08-22 17:00:45: There is a separate array ::tk::Priv.* for each display. The array ::tk::Priv is created using upvar. When an event occurs on a "different" screen, function ChangeScreen() (file generic/tkBind.c) calls proc ::tk::ScreenChanged. This uses upvar to change the per-display array, e.g. ::tk::Priv.:1, that is the upvar target for ::tk::Priv. If GUI activity is on screen A, it is not necessarily a good idea to post a dialog on screen B, but it is not impossible (e.g. when a long-running calculation ends). Then ::tk::ScreenChanged will be called, variable ::tk::Priv will be swapped, and the dialog will exhibit the bug reported here. The solution is to use a variable other than ::tk::Priv as the vwait variable; or to directly use the per-display array tk::Priv.* Branch scaling-fixes does the latter (commit [e984cb7a16]). | |||
Attachments:
- DisplayVwaitBug2.tcl [download] added by kjnash on 2023-08-21 23:34:52. [details]
