From 76481a4de12f52773cfeff0fea2f66eeb77ea1e6 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 17 May 2016 20:36:00 +0000 Subject: Added (currently failing) test case scrollbar-11.1 - Note that it will only fail on x11 and on aqua, not on Win because on Windows there is no binding of <2> for the Scrollbar class --- tests/scrollbar.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 3b16821..8f967ea 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -662,6 +662,24 @@ test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -s destroy .t .s } -result {1.4} +test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { + proc destroy_scrollbar {} { + if {[winfo exists .top.s]} { + destroy .top.s + } + } + toplevel .top + scrollbar .top.s -command destroy_scrollbar + bind .top.s <2> destroy_scrollbar + pack .top.s + focus -force .top.s + update + event generate .top.s <2> + update ; # shall not trigger error invalid command name ".top.s" +} -cleanup { + destroy .top.s .top +} -result {} + catch {destroy .s} catch {destroy .t} -- cgit v0.12 From 19cc8176bca15f76ec939274d61230b3108449f2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 18 May 2016 10:14:33 +0000 Subject: Fixed [011706ec42] for the scrollbar case. --- library/scrlbar.tcl | 11 ++++++++--- tests/scrollbar.test | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index b7be014..6f1caa2 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -430,6 +430,9 @@ proc ::tk::ScrollTopBottom {w x y} { proc ::tk::ScrollButton2Down {w x y} { variable ::tk::Priv + if {![winfo exists $w]} { + return + } set element [$w identify $x $y] if {[string match {arrow[12]} $element]} { ScrollButtonDown $w $x $y @@ -443,7 +446,9 @@ proc ::tk::ScrollButton2Down {w x y} { # slider drag. update idletasks - $w configure -activerelief sunken - $w activate slider - ScrollStartDrag $w $x $y + if {[winfo exists $w]} { + $w configure -activerelief sunken + $w activate slider + ScrollStartDrag $w $x $y + } } diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 8f967ea..bd14067 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -669,8 +669,8 @@ test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi } } toplevel .top - scrollbar .top.s -command destroy_scrollbar - bind .top.s <2> destroy_scrollbar + scrollbar .top.s + bind .top.s <2> {destroy_scrollbar} pack .top.s focus -force .top.s update @@ -679,6 +679,25 @@ test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi } -cleanup { destroy .top.s .top } -result {} +test scrollbar-11.2 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { + proc destroy_scrollbar {{y 0}} { + if {[winfo exists .top.s]} { + destroy .top.s + } + } + toplevel .top + wm minsize .top 50 400 + update + scrollbar .top.s + bind .top.s <2> {after idle destroy_scrollbar} + pack .top.s -expand true -fill y + focus -force .top.s + update + event generate .top.s <2> -x 2 -y [expr {[winfo height .top.s] / 2}] + update ; # shall not trigger error invalid command name ".top.s" +} -cleanup { + destroy .top.s .top +} -result {} catch {destroy .s} catch {destroy .t} -- cgit v0.12