Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fe96ef944999b90e3e9d926598bf3c0f0da86263acc44c0d3375a9eb03ad4413
Ticket: 0221b993a19fd8d1b72db4e79286c0861e7eb83c
Tcl command [update idletasks] doesn't skip main loop in Tcl_DoOneEvent
User & Date: erikleunissen on 2021-03-15 19:09:33
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    Nonwithstanding the intention in the comment, the following code snippet from Tcl_DoOneEvent():
    
    	/*
    	 * If idle events are the only things to service, skip the main part
    	 * of the loop and go directly to handle idle events (i.e. don't wait
    	 * even if TCL_DONT_WAIT isn't set).
    	 */
    
    	if ((flags & TCL_ALL_EVENTS) == TCL_IDLE_EVENTS) {
    	    flags = flags | TCL_DONT_WAIT;
    	    goto idleEvents;
    	}
    
    is bypassed for [update idletasks] because of the presence of the TCL_WINDOW_EVENTS bit in the flags argument, which Tcl_DoOneEvent() receives from  Tcl_UpdateObjCmd():
    
    	switch ((enum updateOptions) optionIndex) {
    	case OPT_IDLETASKS:
    	    flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;	<=== ***
    	    break;
    	default:
    	    Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions");
    	}
    
    I find the presence of TCL_WINDOW_EVENTS in that flags variable suspect. What window events anyway? Especially when comparing with the Tk counterpart Tk_UpdateObjCmd(). In Tk, windows do play a role, but even here the TCL_WINDOW_EVENTS bit is not passed when "update idletasks" is invoked:
    
        if (objc == 1) {
    	flags = TCL_DONT_WAIT;
        } else if (objc == 2) {
    	if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, "option", 0,
    		&index) != TCL_OK) {
    	    return TCL_ERROR;
    	}
    	flags = TCL_IDLE_EVENTS;	<=== ***
        } else {
    	Tcl_WrongNumArgs(interp, 1, objv, "?idletasks?");
    	return TCL_ERROR;
        }
    
  5. foundin changed to: "8.6.11"
  6. is_private changed to: "0"
  7. login: "erikleunissen"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "609f4c7ecf7dbb7a46acdc7eb164753d196088a6"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "erikleunissen"
  14. subsystem changed to: "02. Event Loops"
  15. title changed to:
    Tcl command [update idletasks] doesn't skip main loop in Tcl_DoOneEvent
    
  16. type changed to: "Bug"