diff options
author | treectrl <treectrl> | 2007-01-22 23:29:25 (GMT) |
---|---|---|
committer | treectrl <treectrl> | 2007-01-22 23:29:25 (GMT) |
commit | 5230d625ef19f3049dae228a8a04f4f195e25e17 (patch) | |
tree | 4c70470431bf72e7d32f97141a9575a114158e59 /generic | |
parent | 83be72176d8d2702f1fd4adf62171a5e3811da13 (diff) | |
download | tktreectrl-5230d625ef19f3049dae228a8a04f4f195e25e17.zip tktreectrl-5230d625ef19f3049dae228a8a04f4f195e25e17.tar.gz tktreectrl-5230d625ef19f3049dae228a8a04f4f195e25e17.tar.bz2 |
Tcl_Preserve the associated Tk_Window otherwise we get crashes while freeing config options after a <Destroy> event when the TreeCtrl struct is eventually freed. Reason: if the TreeCtrl struct was Tcl_Preserved before the window was destroyed, then tkwin is NULL when TreeDestroy finally gets called.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkTreeCtrl.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/generic/tkTreeCtrl.c b/generic/tkTreeCtrl.c index 8961b54..9641b2a 100644 --- a/generic/tkTreeCtrl.c +++ b/generic/tkTreeCtrl.c @@ -7,7 +7,7 @@ * Copyright (c) 2002-2003 Christian Krone * Copyright (c) 2003-2005 ActiveState, a division of Sophos * - * RCS: @(#) $Id: tkTreeCtrl.c,v 1.101 2007/01/21 23:18:35 treectrl Exp $ + * RCS: @(#) $Id: tkTreeCtrl.c,v 1.102 2007/01/22 23:29:25 treectrl Exp $ */ #include "tkTreeCtrl.h" @@ -429,6 +429,12 @@ TreeObjCmd( /* Window must exist on Win32. */ TreeTheme_Init(tree); + /* + * Keep a hold of the associated tkwin until we destroy the listbox, + * otherwise Tk might free it while we still need it. + */ + Tcl_Preserve((ClientData) tkwin); + if (Tk_InitOptions(interp, (char *) tree, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(tree->tkwin); return TCL_ERROR; @@ -1781,6 +1787,7 @@ TreeDestroy( AllocHax_Finalize(tree->allocData); #endif + Tcl_Release(tree->tkwin); WFREE(tree, TreeCtrl); } |