Tk Source Code

View Ticket
Login
Ticket UUID: 2799589
Title: script crashes Tk on Win systems
Type: Bug Version: obsolete: 8.5.7
Submitter: dgp Created on: 2009-06-01 18:42:27
Subsystem: 68. Win Window Operations Assigned To: patthoyts
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2009-06-02 16:41:24
Resolution: Fixed Closed By: patthoyts
    Closed on: 2009-06-02 09:41:24
Description:
Chatters on the tkChat confirm that the script
found at:

http://paste.tclers.tk/1609?v=raw

crashes Tk 8.5 programs on Windows systems (XP, Vista).
User Comments: patthoyts added on 2009-06-02 16:41:23:

allow_comments - 1

Backported to 8.5 branch.

patthoyts added on 2009-06-02 16:27:59:
A test added and a fix applied to HEAD

dgp added on 2009-06-02 09:20:08:
thanks for finding it so quickly

patthoyts added on 2009-06-02 07:02:59:
Ah - it seems I added the code that causes this on 7-Jan-2009 for bug #1847002.

patthoyts added on 2009-06-02 06:51:06:
The simplest fix would seem to be:

--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -8260,7 +8260,9 @@ ActivateWindow(

     if (winPtr) {
        if (TkGrabState(winPtr) != TK_GRAB_EXCLUDED) {
-           SetFocus(Tk_GetHWND(winPtr->window));
+           if (winPtr->window) {
+               SetFocus(Tk_GetHWND(winPtr->window));
+           }
        } else {
            SetFocus(Tk_GetHWND(winPtr->dispPtr->grabWinPtr->window));
        }

patthoyts added on 2009-06-02 06:43:45:
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

dkf added on 2009-06-02 05:01:29:
Not reproducible on OSX with either an Aqua build or an X11 build of Tk