after, after_cancel and Python 2.3

Edward K. Ream edreamleo at charter.net
Fri Aug 29 18:25:05 EDT 2003


I just took a look at TK's generic event code in tkEvent.c.  It's really
complex.  For example:

/*
 * There's a potential problem if a handler is deleted while it's
 * current (i.e. its procedure is executing), since Tk_HandleEvent
 * will need to read the handler's "nextPtr" field when the procedure
 * returns.  To handle this problem, structures of the type below
 * indicate the next handler to be processed for any (recursively
 * nested) dispatches in progress.  The nextHandler fields get
 * updated if the handlers pointed to are deleted.  Tk_HandleEvent
 * also needs to know if the entire window gets deleted;  the winPtr
 * field is set to zero if that particular window gets deleted.
 */


This is precisely the situation in which my code fails.



There may be a bug if the list is circular, in which case "updating" the
event handler might not work because p.nextPtr might be p itself.  Also, the
winPtr hack might not work for time-specific events like "after" events.
These are just guesses, and my guess is that there are bugs here somewhere.
Lord!  How does anyone ever get this kind of code to work?



Anyway, I have a workaround...


Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edreamleo at charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------






More information about the Python-list mailing list