git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michele Ballabio <barra_cuda@katamail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: [PATCH] gitk: fix a corner case when switching views
Date: Mon, 3 Mar 2008 20:59:52 +0100	[thread overview]
Message-ID: <200803032059.52960.barra_cuda@katamail.com> (raw)

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


                 reply	other threads:[~2008-03-03 20:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200803032059.52960.barra_cuda@katamail.com \
    --to=barra_cuda@katamail.com \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).