Posted to tcl by dgp at Mon Jun 01 18:31:45 GMT 2009view raw

  1. proc SimpleDialog {} {
  2. global goo
  3. set win .sd
  4. toplevel $win
  5. button $win.b -text "OK" -command {set goo 1}
  6. pack $win.b
  7. update idletasks
  8. tkwait visibility $win
  9. grab $win
  10. tkwait variable goo
  11. grab release $win
  12. # after 0 "destroy $win" ;# This one OK
  13. destroy $win ;# This one crashes
  14. }
  15.  
  16. proc goo { win } {
  17. SimpleDialog
  18. destroy $win
  19. }
  20.  
  21. proc foo { win } {
  22. toplevel $win
  23. button $win.b -text "Do dialog" -command "goo $win"
  24. pack $win.b
  25. }
  26.  
  27.  
  28. button .b -text "Start" -command {foo .t}
  29. 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