summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2008-11-16 17:14:16 (GMT)
committerjenglish <jenglish@flightlab.com>2008-11-16 17:14:16 (GMT)
commitd9fafe1f52ff004f0ff69bd9c137f8ac0ffa1a85 (patch)
tree85462e1e5bc712fd9adae557c8182937658d0205
parentc06d8b5997ceab121a63b035b9cbe666d78bdbec (diff)
downloadtk-d9fafe1f52ff004f0ff69bd9c137f8ac0ffa1a85.zip
tk-d9fafe1f52ff004f0ff69bd9c137f8ac0ffa1a85.tar.gz
tk-d9fafe1f52ff004f0ff69bd9c137f8ac0ffa1a85.tar.bz2
Widget self-destruction is not necessarily an error [Bug 2298720].
-rw-r--r--ChangeLog5
-rw-r--r--generic/ttk/ttkEntry.c5
-rw-r--r--generic/ttk/ttkWidget.c10
-rw-r--r--tests/ttk/ttk.test10
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 <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkWidget.c: Widget self-destruction is
+ not necessarily an error [Bug 2298720].
+
2008-11-16 Donal K. Fellows <dkf@users.sf.net>
* 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.
#