summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tests/wm.test39
-rw-r--r--win/tkWinWm.c20
3 files changed, 55 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 20a8877..592ddc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-01 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * win/tkWinWm.c: Backported fixes for handling unmapped parent
+ * test/wm.test: toplevels. [Bug 2009788, 2028703]
+
2008-07-31 Don Porter <dgp@users.sourceforge.net>
* generic/tk.h: Added missing EXTERN for the Tcl_PkgInitStubsCheck
diff --git a/tests/wm.test b/tests/wm.test
index a5586bd..7e2e484 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: wm.test,v 1.39 2008/03/20 13:23:20 dkf Exp $
+# RCS: @(#) $Id: wm.test,v 1.39.2.1 2008/08/01 20:24:48 patthoyts Exp $
# This file tests window manager interactions that work across platforms.
# Window manager tests that only work on a specific platform should be placed
@@ -2138,6 +2138,43 @@ test wm-manage-1.2 {unmanaging a toplevel} -setup {
deleteWindows
} -result {wm .t.t pack .t wm .t.t}
+test wm-forget-1.1 "bug #2009788: forget toplevel can cause crash" -body {
+ toplevel .parent
+ toplevel .parent.child
+ wm forget .parent.child
+ winfo exists .parent.child
+} -cleanup {
+ deleteWindows
+} -result {1}
+test wm-forget-1.2 "bug #2009788: forget toplevel can cause crash" -body {
+ toplevel .parent
+ update
+ toplevel .parent.child
+ wm forget .parent.child
+ winfo exists .parent.child
+} -cleanup {
+ deleteWindows
+} -result {1}
+test wm-forget-1.3 "bug #2009788: forget toplevel can cause crash" -body {
+ toplevel .parent
+ toplevel .parent.child
+ wm forget .parent.child
+ wm manage .parent.child
+ winfo exists .parent.child
+} -cleanup {
+ deleteWindows
+} -result {1}
+test wm-forget-1.4 "pack into unmapped toplevel causes crash" -body {
+ toplevel .parent
+ toplevel .parent.child
+ wm forget .parent.child
+ pack [button .parent.child.button -text Hello]
+ after 250 {destroy .parent}
+ tkwait window .parent
+} -cleanup {
+ deleteWindows
+} -result {}
+
# FIXME:
# Test delivery of virtual events to the WM. We could check to see if the
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index d9fc1ac..4f891ee 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 2007/12/14 15:56:09 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.124.2.1 2008/08/01 20:24:50 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -3706,7 +3706,9 @@ WmForgetCmd(tkwin, winPtr, interp, objc, objv)
if (Tk_IsTopLevel(frameWin)) {
Tk_UnmapWindow(frameWin);
winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
- RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
+ if (Tk_IsMapped(Tk_Parent(frameWin))) {
+ RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
+ }
TkWmDeadWindow(winPtr);
/* flags (above) must be cleared before calling */
/* TkMapTopFrame (below) */
@@ -5872,13 +5874,15 @@ TopLevelReqProc(
WmInfo *wmPtr;
wmPtr = winPtr->wmInfoPtr;
- if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) {
- SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
+ if (wmPtr) {
+ if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) {
+ SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
Tk_ReqHeight(tkwin));
- }
- if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
- wmPtr->flags |= WM_UPDATE_PENDING;
+ }
+ if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
+ wmPtr->flags |= WM_UPDATE_PENDING;
+ }
}
}