summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-05-25 19:36:21 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-05-25 19:36:21 (GMT)
commite0623338b763404cfa939a5be23f880dbb89c75d (patch)
tree39ad7f79f0681e3b934d7595415c6db968618e2c
parent9fa60a52311330031fc9c79d6169fa8683e117c1 (diff)
parent6ceb9aa8c5ae688f8f59178fb7b1139ce657b1ae (diff)
downloadtk-e0623338b763404cfa939a5be23f880dbb89c75d.zip
tk-e0623338b763404cfa939a5be23f880dbb89c75d.tar.gz
tk-e0623338b763404cfa939a5be23f880dbb89c75d.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 ad57020..648cdee 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