Skip to content

Commit d98d50e

Browse files
committed
gitk: Fix linehtag undefined error with file highlighting
Occasionally gitk will throw a Tcl error complaining that linehtag(n) is undefined when. It happens when the commit list is still growing (e.g. when updating the commit list) and gitk is set to highlight commits that affect certain file(s). What happens is that the changes to the commit list set need_redisplay to indicate that the display needs to be redrawn. That causes the next call to drawcommits to call clear_display, which unsets iddrawn and thus ensures that readfhighlight won't call bolden on any rows that have moved. However, it is possible for readfhighlight to be called after the commit list has changed but before drawcommits has run, meaning that readfhighlight will potentially think that rows have been drawn when they haven't, because of the change in the id -> row mapping (and the fact that iddrawn is indexed by id but line[hnd]tag are indexed by row number). This fixes it (and also optimizes things a little) by making bolden and bolden_name check need_redisplay before doing anything. If need_redisplay is set, then there is no point doing anything because the whole display is about to get cleared and redrawn, and it avoids looking up line[hn]tag using stale row numbers. Signed-off-by: Paul Mackerras <[email protected]>
1 parent 590915d commit d98d50e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gitk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,8 +4005,10 @@ proc ishighlighted {id} {
40054005
}
40064006

40074007
proc bolden {row font} {
4008-
global canv linehtag selectedline boldrows
4008+
global canv linehtag selectedline boldrows need_redisplay
40094009

4010+
# need_redisplay = 1 means the display is stale and about to be redrawn
4011+
if {$need_redisplay} return
40104012
lappend boldrows $row
40114013
$canv itemconf $linehtag($row) -font $font
40124014
if {$row == $selectedline} {
@@ -4019,8 +4021,9 @@ proc bolden {row font} {
40194021
}
40204022

40214023
proc bolden_name {row font} {
4022-
global canv2 linentag selectedline boldnamerows
4024+
global canv2 linentag selectedline boldnamerows need_redisplay
40234025

4026+
if {$need_redisplay} return
40244027
lappend boldnamerows $row
40254028
$canv2 itemconf $linentag($row) -font $font
40264029
if {$row == $selectedline} {

0 commit comments

Comments
 (0)