summaryrefslogtreecommitdiffstats
path: root/generic/tkPanedWindow.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-10-08 19:57:48 (GMT)
committerhobbs <hobbs>2002-10-08 19:57:48 (GMT)
commit0be889cba49f585258c7dced520fa81a0b8f9a65 (patch)
tree301b1e3aaafdcf26c12caa11017247b17e2144ed /generic/tkPanedWindow.c
parentec4bc2494c4fb1810aa082909fbcd8c6ce865a1d (diff)
downloadtk-0be889cba49f585258c7dced520fa81a0b8f9a65.zip
tk-0be889cba49f585258c7dced520fa81a0b8f9a65.tar.gz
tk-0be889cba49f585258c7dced520fa81a0b8f9a65.tar.bz2
* generic/tkPanedWindow.c (Tk_PanedWindowObjCmd): leave the
DestroyPanedWindow proc to free the pwPtr, add a Preserve reference to the pwPtr->tkwin. (DestroyPanedWindow): Release the pwPtr->tkwin.
Diffstat (limited to 'generic/tkPanedWindow.c')
-rw-r--r--generic/tkPanedWindow.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index c419847..efc4793 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.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: tkPanedWindow.c,v 1.9 2002/09/30 18:55:57 hobbs Exp $
+ * RCS: @(#) $Id: tkPanedWindow.c,v 1.10 2002/10/08 19:57:48 hobbs Exp $
*/
#include "tkPort.h"
@@ -389,10 +389,16 @@ Tk_PanedWindowObjCmd(clientData, interp, objc, objv)
pwPtr->cursor = None;
pwPtr->sashCursor = None;
+ /*
+ * Keep a hold of the associated tkwin until we destroy the widget,
+ * otherwise Tk might free it while we still need it.
+ */
+
+ Tcl_Preserve((ClientData) pwPtr->tkwin);
+
if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions,
tkwin) != TCL_OK) {
Tk_DestroyWindow(pwPtr->tkwin);
- ckfree((char *) pwPtr);
return TCL_ERROR;
}
@@ -416,11 +422,10 @@ Tk_PanedWindowObjCmd(clientData, interp, objc, objv)
pwPtr->proxywin = Tk_CreateAnonymousWindow(interp, parent, (char *) NULL);
Tk_CreateEventHandler(pwPtr->proxywin, ExposureMask, ProxyWindowEventProc,
(ClientData) pwPtr);
-
+
if (ConfigurePanedWindow(interp, pwPtr, objc - 2, objv + 2) != TCL_OK) {
Tk_DestroyWindow(pwPtr->proxywin);
Tk_DestroyWindow(pwPtr->tkwin);
- ckfree((char *) pwPtr);
return TCL_ERROR;
}
@@ -1466,18 +1471,19 @@ DestroyPanedWindow(pwPtr)
if (pwPtr->slaves) {
ckfree((char *) pwPtr->slaves);
}
-
+
/*
* Remove the widget command from the interpreter.
*/
Tcl_DeleteCommandFromToken(pwPtr->interp, pwPtr->widgetCmd);
-
+
/*
* Let Tk_FreeConfigOptions clean up the rest.
*/
-
+
Tk_FreeConfigOptions((char *) pwPtr, pwPtr->optionTable, pwPtr->tkwin);
+ Tcl_Release((ClientData) pwPtr->tkwin);
pwPtr->tkwin = NULL;
Tcl_EventuallyFree((ClientData) pwPtr, TCL_DYNAMIC);