Tk Source Code

Ticket Change Details
Login
Overview

Artifact ID: 61082efdcf028914b0dcb3bbbc19f3549143732a
Ticket: bc4552d0bb8d4489b1d9675bbf7e0873d32bdb0c
Tcl_SetServiceMode in nextEventMatchingMask can be removed
User & Date: anonymous 2014-01-23 14:08:43
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    In the nextEventMatchingMask method in macosx/tkMacOSXNotify.c, in this section:
    
    @implementation TKApplication(TKNotify)
    - (NSEvent *) nextEventMatchingMask: (NSUInteger) mask
            untilDate: (NSDate *) expiration inMode: (NSString *) mode
            dequeue: (BOOL) deqFlag
    {
    ...
        int oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
        NSEvent *event = [[super nextEventMatchingMask:mask untilDate:expiration
                inMode:mode dequeue:deqFlag] retain];
        Tcl_SetServiceMode(oldMode);
    ...
    }
    
    we first set the service mode using Tcl_SetServiceMode, then we call the nextEventMatchingMask method of the superclass, and then we restore the original service mode.
    
    The Tcl_SetServiceMode function (in generic/tclNotify.c) is the following:
    
    int Tcl_SetServiceMode(int mode)
    {
        int oldMode;
        ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
        oldMode = tsdPtr->serviceMode;
        tsdPtr->serviceMode = mode;
        Tcl_ServiceModeHook(mode);
        return oldMode;
    }
    
    Now the superclass nextEventMatchingMask method simply gets the next available event, but does not invoke any Tcl/Tk code. So setting tsdPtr->serviceMode has no consequences.
    
    The Tcl_ServiceModeHook function (in macosx/tclMacOSXNotify.c) creates the runloop timer if it doesn’t already exist. But since we also call Tcl_SetServiceMode from Tk_MacOSXSetupTkNotifier during Tk initialization, the runloop timer already exist by the time we call nextEventMatchingMask.
    
    So I think the two calls to Tcl_SetServiceMode in the nextEventMatchingMask method can be removed. The patch does just that. This patch was made relative to this patch which I submitted previously:
    
    https://core.tcl.tk/tcl/tktview?name=883155fb98
    
    However, these two patches can be applied independently of each other.
    
  5. foundin changed to: "trunk"
  6. is_private changed to: "0"
  7. login: "anonymous"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "500c9a7a4e11b3ea0441850610e04006941c0cf3"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "anonymous"
  14. subsystem changed to: "70. Event Loop"
  15. title changed to:
    Tcl_SetServiceMode in nextEventMatchingMask can be removed
    
  16. type changed to: "Patch"