Posted to tcl by dgp at Mon Jun 01 18:31:45 GMT 2009view raw
- proc SimpleDialog {} {
- global goo
- set win .sd
- toplevel $win
- button $win.b -text "OK" -command {set goo 1}
- pack $win.b
- update idletasks
- tkwait visibility $win
- grab $win
- tkwait variable goo
- grab release $win
- # after 0 "destroy $win" ;# This one OK
- destroy $win ;# This one crashes
- }
- proc goo { win } {
- SimpleDialog
- destroy $win
- }
- proc foo { win } {
- toplevel $win
- button $win.b -text "Do dialog" -command "goo $win"
- pack $win.b
- }
- button .b -text "Start" -command {foo .t}
- pack .b
Comments
Posted by patthoyts at Mon Jun 01 23:41:56 GMT 2009 [text] [code]
Because a grab is in place when one window is activated the activation is posted as an event. When this event is handled the target window has been destroyed and the window member of the TkWindow is 0. This is passed to Tk_GetHWND which does not expect to receive NULL values as Window pointers and throws an exception. Probably we should check in tkWinWm.c:ActivateWindow that the grab state is not TK_GRAB_NONE or just check the winPtr->window is non-nil