summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tests/winWm.test51
-rw-r--r--win/tkWinWm.c16
3 files changed, 68 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 6bd62c2..70534c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-06-02 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/tkWinWm.c: [Bug 2799589] Backported fix for crash on
+ * tests/winWm.test: delayed window activation.
+
2009-05-21 Pat Thoyts <patthoyts@users.sourceforge.net>
* win/tkWinMenu.c: [Bug 2794778]: Backported fix for keyboard
diff --git a/tests/winWm.test b/tests/winWm.test
index 0b5592a..c69226b 100644
--- a/tests/winWm.test
+++ b/tests/winWm.test
@@ -9,7 +9,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: winWm.test,v 1.18 2006/12/01 19:48:00 hobbs Exp $
+# RCS: @(#) $Id: winWm.test,v 1.18.4.1 2009/06/02 09:41:42 patthoyts Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -370,8 +370,57 @@ test winWm-8.2 {Tk_WmCmd procedure, "iconphoto" option} win {
image delete blank16 blank32
} {}
+test winWm-9.0 "Bug #2799589 - delayed activation of destroyed window" -setup {
+ proc winwm90click {w} {
+ if {![winfo ismapped $w]} { update }
+ event generate $w <Enter>
+ focus -force $w
+ event generate $w <ButtonPress-1> -x 5 -y 5
+ event generate $w <ButtonRelease-1> -x 5 -y 5
+ }
+ proc winwm90proc3 {} {
+ global winwm90done winwm90check
+ set w .sd
+ toplevel $w
+ pack [button $w.b -text "OK" -command {set winwm90check 1}]
+ bind $w.b <Map> {after idle {winwm90click %W}}
+ update idletasks
+ tkwait visibility $w
+ grab $w
+ tkwait variable winwm90check
+ grab release $w
+ destroy $w
+ after idle {set winwm90done ok}
+ }
+ proc winwm90proc2 {w} { winwm90proc3; destroy $w }
+ proc winwm90proc1 {w} {
+ toplevel $w
+ pack [button $w.b -text "Do dialog" -command [list winwm90proc2 $w]]
+ bind $w.b <Map> {bind %W <Map> {}; after idle {winwm90click %W}}
+ }
+ destroy .t
+ global winwm90done
+ set winwm90done wait
+ toplevel .t
+} -body {
+ pack [button .t.b -text "Show" -command {winwm90proc1 .tx}]
+ bind .t.b <Map> {bind %W <Map> {}; after idle {winwm90click %W}}
+ after 5000 {set winwm90done timeout}
+ vwait winwm90done
+ set winwm90done
+} -cleanup {
+ foreach cmd {proc1 proc2 proc3 click} {
+ rename winwm90$cmd {}
+ }
+ destroy .tx .t .sd
+} -result {ok}
+
destroy .t
# cleanup
cleanupTests
return
+
+# Local variables:
+# mode: tcl
+# End:
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index b18318f..2af53eb 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.124.2.5 2009/05/03 06:48:55 dkf Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.124.2.6 2009/06/02 09:41:42 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -8283,10 +8283,20 @@ ActivateWindow(
*/
if (winPtr) {
+ Window window;
if (TkGrabState(winPtr) != TK_GRAB_EXCLUDED) {
- SetFocus(Tk_GetHWND(winPtr->window));
+ window = winPtr->window;
} else {
- SetFocus(Tk_GetHWND(winPtr->dispPtr->grabWinPtr->window));
+ window = winPtr->dispPtr->grabWinPtr->window;
+ }
+
+ /*
+ * Ensure the window was not destroyed while we were postponing
+ * the activation [Bug 2799589]
+ */
+
+ if (window) {
+ SetFocus(Tk_GetHWND(window));
}
}