gitk: Fix "can't unset prevlines(...)" Tcl error

This fixes the error reported by Michele Ballabio, where gitk will
throw a Tcl error "can't unset prevlines(...)" when displaying a
commit that has a parent commit listed more than once, and the commit
is the first child of that parent.

The problem was basically that we had two variables, prevlines and
lineends, and were relying on the invariant that prevlines($id) was
set iff $id was in the lineends($r) list for some $r.  But having
a duplicate parent breaks that invariant since we end up with the
parent listed twice in lineends.

This fixes it by simplifying the logic to use only a single variable,
lineend.  It also rearranges things a little so that we don't try to
draw the line for the duplicated parent twice.

Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Paul Mackerras 2007-10-21 12:58:42 +10:00
Родитель 3ebba3c724
Коммит e5ef6f952a
1 изменённых файлов: 5 добавлений и 16 удалений

21
gitk
Просмотреть файл

@ -3695,34 +3695,23 @@ proc drawcommits {row {endrow {}}} {
drawcmitrow $r
if {$r == $er} break
set nextid [lindex $displayorder [expr {$r + 1}]]
if {$wasdrawn && [info exists iddrawn($nextid)]} {
catch {unset prevlines}
continue
}
if {$wasdrawn && [info exists iddrawn($nextid)]} continue
drawparentlinks $id $r
if {[info exists lineends($r)]} {
foreach lid $lineends($r) {
unset prevlines($lid)
}
}
set rowids [lindex $rowidlist $r]
foreach lid $rowids {
if {$lid eq {}} continue
if {[info exists lineend($lid)] && $lineend($lid) > $r} continue
if {$lid eq $id} {
# see if this is the first child of any of its parents
foreach p [lindex $parentlist $r] {
if {[lsearch -exact $rowids $p] < 0} {
# make this line extend up to the child
set le [drawlineseg $p $r $er 0]
lappend lineends($le) $p
set prevlines($p) 1
set lineend($p) [drawlineseg $p $r $er 0]
}
}
} elseif {![info exists prevlines($lid)]} {
set le [drawlineseg $lid $r $er 1]
lappend lineends($le) $lid
set prevlines($lid) 1
} else {
set lineend($lid) [drawlineseg $lid $r $er 1]
}
}
}