Widget destruction, and resource management in general, is one of the trickier things to get right in a Tk widget implementation. There are more bugs per square foot in this area of the core than anywhere else.
What I'm looking for is a recipe for how to properly handle the widget lifecycle. (When I asked about this on the chatroom, DGP said: "typically there's a "deleted" flag in the struct, and lots of Tcl_Preserve()'s around." But there are apparently no formalized guidelines anywhere...)
There are several cases to handle:
There are probably more ....
more to come ...
Another complication: When the event handler destroys the widget command, thanks to command deletion traces it's possible for the interpreter to be recursively reentered.