Tk Source Code

View Ticket
Login
Ticket UUID: 73c5e3ad3fd8b1201c16ffe45d3005957defc67b
Title: Two potentially bogus binding scripts for <TouchpadScroll>
Type: Bug Version: 9.0, trunk
Submitter: nemethi Created on: 2024-10-15 14:07:03
Subsystem: 01. Bindings Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2024-10-16 09:04:49
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2024-10-16 09:04:49
Description:

In the Tk library files listbox.tcl and ttk/utils.tcl, the binding scripts for <TouchpadScroll> start with

    if {%# %% 5 != 0} {
        return
    }

According to  man n bind,  a binding script may invoke the continue and break commands.  Invocations of return are not explictly prohibited, but they can have unexpected side effects, as shown when running the attached script with Tk 9 on Windows or Aqua and using the touchpad for scrolling within the listbox.  A few seconds after starting the scrolling via two-finger gestures, a dialog containing the error message "command returned bad code: 2" pops up.  I think the error code 2 is due to the fact that the above return is interpreted to be equivalent to  return -code return,  i.e.,   return -code 2.

The test script makes use of the potentially dangerous plain update command.  With  update idletasks I wasn't able to reproduce the error.

To avoid such unexpected side effects, the return in the two above-mentioned binding scripts should be replaced with continue.  I have tested it, with the result that the error message mentined above was no longer reproducible.  If nobody objects, I am going to commit this change in trunk and core-8-branch wihin the next few days.

User Comments: jan.nijtmans added on 2024-10-16 09:04:49:

Fixed [077e11595fdfd5df|here]


nemethi (claiming to be Csaba Nemethi) added on 2024-10-15 15:04:58:

Thanks Jan, your patch is equivalent to the one proposed by me.


jan.nijtmans added on 2024-10-15 14:50:20:

How about something like [ef6d0286ea244449|this]?


Attachments: