gitk: Avoid Tcl error when switching views
Michele Ballabio <barra_cuda@katamail.com> pointed out that gitk sometimes throws a Tcl error (can't read "yscreen") when switching views, and proposed a patch. This is a different way of fixing it which is a bit neater. Basically, in showview we only set yscreen if the selected commit is on screen to start with, and then we only scroll the canvas to bring it onscreen if yscreen is set and the same commit exists in the new view. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Mar 11, 2008 at 22:11 UTC
494d3b8a6c93d88daf4a52dbcc6ab07903f8ed4e
1 file changed
+1
-3
gitk
+1
-3
@@ -2102,8 +2102,6 @@ proc showview {n} {
2102
set ybot [expr {[lindex $span 1] * $ymax}]
2103
if {$ytop < $y && $y < $ybot} {
2104
set yscreen [expr {$y - $ytop}]
2105
- } else {
2106
- set yscreen [expr {($ybot - $ytop) / 2}]
2105
}
2106
} elseif {[info exists pending_select]} {
2107
set selid $pending_select
@@ -2164,7 +2162,7 @@ proc showview {n} {
2162
set yf 0
2163
set row {}
2164
set selectfirst 0
2167
- if {$selid ne {} && [info exists commitrow($n,$selid)]} {
2165
+ if {[info exists yscreen] && [info exists commitrow($n,$selid)]} {
2166
set row $commitrow($n,$selid)
2167
# try to get the selected row in the same position on the screen
2168
set ymax [lindex [$canv cget -scrollregion] 3]