Tk Source Code

View Ticket
Login
Ticket UUID: 9e487e9f158b3aeda2b92ca75deb3abc04e21a61
Title: Fix for tkWinButton to avoid problems in plugin
Type: Patch Version: 8.5.x
Submitter: anonymous Created on: 2014-09-30 11:10:05
Subsystem: 03. [*button] and [label] Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2014-10-11 20:03:22
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2014-10-11 20:03:22
Description:
Change the event handler code to prevent it from handling WM_NULL messages. Those are used by some browsers to make sure a plugin is still alive and responsive. Without the modification the plugin is not useable in those browsers.


   case BN_CLICKED: {
        /*
         * OOPS: chromium fires WM_NULL regularly to ping if plugin is still
         * alive. When using an external window (i.e. via the tcl plugin), this
         * causes all buttons to fire once a second, so we need to make sure
         * that we are not dealing with the chromium life check.
         */
        if(!(message == WM_NULL && wParam == 0 && lParam == 0)) {
            int code;
            Tcl_Interp *interp = butPtr->info.interp;

            if (butPtr->info.state != STATE_DISABLED) {
                Tcl_Preserve((ClientData)interp);
                code = TkInvokeButton((TkButton*)butPtr);
                if (code != TCL_OK && code != TCL_CONTINUE
                    && code != TCL_BREAK) {
                    Tcl_AddErrorInfo(interp, "\n    (button invoke)");
                    Tcl_BackgroundException(interp, code);
                }
                Tcl_Release((ClientData)interp);
            }
            Tcl_ServiceAll();
            return 0;
        }

    }
User Comments: jan.nijtmans added on 2014-10-11 20:03:22:

Even though no feedback is received, this suggestion looks harmless enough to be applied. So, it's in core-8-5-branch [d093221415b127f26d3e1d970af0bfd9f7371a7f|d093221415] and trunk [2a9f4ee0083acd172ceffc6dbafb01f3a0eda1ca|2a9f4ee008]


jan.nijtmans added on 2014-10-01 18:45:19:

See: [a0b6440052fee25871346d2c07335be30a711a71|a0b6440052]. Since WM_NULL and BN_CLICKED have the same numerical value, the first test is always true.

Agreed with analysis. Please test this branch, if it works I will merge it to core-8-5-branch and trunk.