From 0b665a5f96ac317bcaca3d9debba6df056468319 Mon Sep 17 00:00:00 2001 From: "jenglish@flightlab.com" Date: Sun, 16 Nov 2008 17:14:16 +0000 Subject: Widget self-destruction is not necessarily an error [Bug 2298720]. --- ChangeLog | 5 +++++ generic/ttk/ttkEntry.c | 5 ++--- generic/ttk/ttkWidget.c | 10 +++++----- tests/ttk/ttk.test | 10 +++++++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 981a9c6..fa58d7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-16 Joe English + + * generic/ttk/ttkWidget.c: Widget self-destruction is + not necessarily an error [Bug 2298720]. + 2008-11-16 Donal K. Fellows * doc/wm.n: Added note about [wm overrideredirect] so that users will diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index ce07ed9..edf49a0 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1,5 +1,5 @@ /* - * $Id: ttkEntry.c,v 1.12 2008/11/09 23:53:09 jenglish Exp $ + * $Id: ttkEntry.c,v 1.13 2008/11/16 17:14:16 jenglish Exp $ * * DERIVED FROM: tk/generic/tkEntry.c r1.35. * @@ -1709,12 +1709,11 @@ typedef struct { {TK_OPTION_STRING, "-values", "values", "Values", \ "", Tk_Offset(Values, values.valuesObj), -1, 0, 0, VALUES_CHANGED} -static int +static void ValuesInitialize(Tcl_Interp *interp, void *recordPtr) { Values *valPtr = recordPtr; valPtr->values.currentIndex = -1; - return TCL_OK; } static int diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index c2cb2b6..9f8e0a4 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -1,4 +1,4 @@ -/* $Id: ttkWidget.c,v 1.18 2008/11/13 01:13:54 jenglish Exp $ +/* $Id: ttkWidget.c,v 1.19 2008/11/16 17:14:16 jenglish Exp $ * Copyright (c) 2003, Joe English * * Core widget utilities. @@ -183,10 +183,6 @@ WidgetInstanceObjCmd( Tcl_Preserve(clientData); status = TtkWidgetEnsembleCommand(commands,1, interp,objc,objv,clientData); - if (WidgetDestroyed(corePtr)) { - status = TCL_ERROR; - Tcl_SetResult(interp, "Widget has been destroyed", TCL_STATIC); - } Tcl_Release(clientData); return status; @@ -664,6 +660,10 @@ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr) Tk_FreeSavedOptions(&savedOptions); status = corePtr->widgetSpec->postConfigureProc(interp,recordPtr,mask); + if (WidgetDestroyed(corePtr)) { + Tcl_SetResult(interp, "Widget has been destroyed", TCL_STATIC); + status = TCL_ERROR; + } if (status != TCL_OK) { return status; } diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index e050e2a..2bb3d04 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -23,7 +23,7 @@ test ttk-6.1 "Self-destructing checkbutton" -body { trace variable sd w [list selfdestruct .sd] update .sd invoke -} -returnCodes 1 -result "Widget has been destroyed" +} -returnCodes 1 test ttk-6.2 "Checkbutton self-destructed" -body { winfo exists .sd } -result 0 @@ -118,6 +118,14 @@ test ttk-construction-failure-2 "Destroy widget in constructor" -setup { ; } -result [list 1 "Widget has been destroyed" 0 {}] +test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { + # see #2298720 + toplevel .t + ttk::button .t.b -command [list destroy .t] + .t.b invoke + list [winfo exists .t] [winfo exists .t.b] +} -result [list 0 0] + # # Basic tests. # -- cgit v0.12