git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitk: fix a corner case when switching views
@ 2008-03-03 19:59 Michele Ballabio
  0 siblings, 0 replies; only message in thread
From: Michele Ballabio @ 2008-03-03 19:59 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

Switching from a view that shows no commit ("No commits selected")
to another view, back and forth, can trigger an error like:

	can't read "yscreen": no such variable
	can't read "yscreen": no such variable
	    while executing
	"expr {[yc $row] - $yscreen}"
	    (procedure "showview" line 91)
	    invoked from within
	"showview 2"
	    invoked from within
	".#bar.#bar#view invoke active"
	    ("uplevel" body line 1)
	    invoked from within
	"uplevel #0 [list $w invoke active]"
	    (procedure "tk::MenuInvoke" line 50)
	    invoked from within
	"tk::MenuInvoke .#bar.#bar#view 1"
	    (command bound to event)

This patch avoids this with a check on yscreen and ytop in procedure
showview.

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
---
 gitk |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gitk b/gitk
index f1f21e9..371654f 100755
--- a/gitk
+++ b/gitk
@@ -2124,11 +2124,15 @@ proc showview {n} {
 	set row $commitrow($n,$selid)
 	# try to get the selected row in the same position on the screen
 	set ymax [lindex [$canv cget -scrollregion] 3]
-	set ytop [expr {[yc $row] - $yscreen}]
-	if {$ytop < 0} {
-	    set ytop 0
+	if {[info exists yscreen]} {
+	    set ytop [expr {[yc $row] - $yscreen}]
+	}
+	if {[info exists ytop]} {
+	    if {$ytop < 0} {
+		set ytop 0
+	    }
+	    set yf [expr {$ytop * 1.0 / $ymax}]
 	}
-	set yf [expr {$ytop * 1.0 / $ymax}]
     }
     allcanvs yview moveto $yf
     drawvisible
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-03-03 20:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-03 19:59 [PATCH] gitk: fix a corner case when switching views Michele Ballabio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).