summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-05-25 19:35:36 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-05-25 19:35:36 (GMT)
commit6ceb9aa8c5ae688f8f59178fb7b1139ce657b1ae (patch)
tree8f45747111a0be81d61caec3707a94f5eaf3d8a3
parent2f150c8d18e576998e9d30ac08c562a1365b3051 (diff)
parenta129a2159a084a7ead331d54273f5cf2a3a7a961 (diff)
downloadtk-6ceb9aa8c5ae688f8f59178fb7b1139ce657b1ae.zip
tk-6ceb9aa8c5ae688f8f59178fb7b1139ce657b1ae.tar.gz
tk-6ceb9aa8c5ae688f8f59178fb7b1139ce657b1ae.tar.bz2
Fixed [109865fa01] - ttk::menubutton unsafe wrt widget destruction
-rw-r--r--library/ttk/menubutton.tcl2
-rw-r--r--tests/ttk/checkbutton.test16
2 files changed, 17 insertions, 1 deletions
diff --git a/library/ttk/menubutton.tcl b/library/ttk/menubutton.tcl
index 093bb02..2be064c 100644
--- a/library/ttk/menubutton.tcl
+++ b/library/ttk/menubutton.tcl
@@ -57,7 +57,7 @@ if {[tk windowingsystem] eq "x11"} {
bind TMenubutton <ButtonPress-1> \
{ %W state pressed ; ttk::menubutton::Popdown %W }
bind TMenubutton <ButtonRelease-1> \
- { %W state !pressed }
+ { if {[winfo exists %W]} { %W state !pressed } }
}
# PostPosition --
diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test
index e18ff32..6b79287 100644
--- a/tests/ttk/checkbutton.test
+++ b/tests/ttk/checkbutton.test
@@ -45,4 +45,20 @@ test checkbutton-1.6 "Checkbutton default variable" -body {
lappend result [info exists .cb] [set .cb] [.cb state]
} -result [list .cb 0 alternate 1 on selected 1 off {}]
+# Bug [109865fa01]
+test checkbutton-1.7 "Button destroyed by click" -body {
+ proc destroy_button {} {
+ destroy .top
+ }
+ toplevel .top
+ ttk::menubutton .top.mb -text Button -style TLabel
+ bind .top.mb <ButtonRelease-1> destroy_button
+ pack .top.mb
+ focus -force .top.mb
+ update
+ event generate .top.mb <1>
+ event generate .top.mb <ButtonRelease-1>
+ update ; # shall not trigger error invalid command name ".top.b"
+} -result {}
+
tcltest::cleanupTests