Tk Source Code

View Ticket
Login
Ticket UUID: 7447ed20eced8b2eeb65fbb56fdf555e155e4a61
Title: Color picker failure
Type: Bug Version: 8.6.13
Submitter: erikleunissen Created on: 2023-05-23 11:18:49
Subsystem: 34. [tk_chooseColor] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-05-25 06:16:47
Resolution: Fixed Closed By: fvogel
    Closed on: 2023-05-25 06:16:47
Description:
The Tk colorpicker widget fails if there is a grab on a window in another Tk interpreter/application, which happens to have the same window pathname as a window that exists in the interpreter where the color picker is invoked. This was observed on Linux/X11.

The failure can be reproduced by running the attached Tk script exercise.tcl.

After clicking on the OK or the Cancel button in the color picker dialog, the following error is thrown:

# grab failed: another application has grab
#     while executing
# "grab $oldGrab"
#     (procedure "::tk::RestoreFocusGrab" line 21)
#     invoked from within
# "::tk::RestoreFocusGrab $w $data(okBtn)"
#     (procedure "::tk::dialog::color::" line 79)
#     invoked from within
# "::tk::dialog::color:: {*}$args"
#     (procedure "tk_chooseColor" line 2)
#     invoked from within
# "tk_chooseColor"
#     invoked from within
# "interp eval other {
#         package require Tk
#         pack [frame .f -width 20 -height 20 -bg blue]; # name collision with the parent interpreter
#         wm deiconify .
#         ..."
#     (file "./exercise.tcl" line 9)

I found the reason for the problem in proc tk::RestoreFocusGrab (in file tk.tcl). This proc doesn't count with a name collision as described above.
The attached patch, based on Tk 8.6.13, fixes the problem.
User Comments: fvogel added on 2023-05-25 06:16:47:
Merged in core-8-6-branch and trunk. Thanks!

erikleunissen added on 2023-05-24 06:09:56:
Thanks for the review and inclusion in Fossil,
 
B.t.w. : I believe that it's wise to have added the comment, and agree wholeheartedly.

fvogel added on 2023-05-23 19:02:01:

Reproduced (on Linux).

I agree with the fix. tk::SetFocusGrab also catches the grab, for the same reason. I have committed your patch, enriched with a comment as [d25b5a7e].

Thanks!


oehhar added on 2023-05-23 11:54:07:

Eric, great that you care and provide a patch, I appreciate.

Magic Francois has recently fixed bug [3414695] with a similar signature.

Have you checked by chance, if this also fixes the issue of this bug?

Thanks again, Harald


Attachments: