Tk Library Source Code

Artifact [264c5bc45b]
Login

Artifact 264c5bc45b20d0f26d5480e2836419bc535a8d4c:

Attachment "bwidget-tree.patch" to ticket [3106208fff] added by andreas_kupries 2010-11-10 03:30:55.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/bwidget/ChangeLog,v
retrieving revision 1.219
diff -w -u -r1.219 ChangeLog
--- ChangeLog	9 Nov 2010 16:04:45 -0000	1.219
+++ ChangeLog	9 Nov 2010 20:25:35 -0000
@@ -4,6 +4,15 @@
 #  $Id: ChangeLog,v 1.219 2010/11/09 16:04:45 oehhar Exp $
 # ------------------------------------------------------------------------------
 
+2010-11-09  Andreas Kupries  <[email protected]>
+
+	* tree.tcl (Tree::itemconfigure): Fix intermingling of node names
+	and flag values which can cause an lsearch to fail, by mistaking a
+	flag value as the node searched for, and then treating a node name
+	as flags. As the upd,nodes value is a dictionary it should not be
+	search as a list. Now using a temporary array for quicker check
+	and append/replace.
+
 2010-11-09 Harald Oehlmann <[email protected]>
 
 	* mainframe.tcl Menu text shows white on white on Mac aqua
Index: tree.tcl
===================================================================
RCS file: /cvsroot/tcllib/bwidget/tree.tcl,v
retrieving revision 1.62
diff -w -u -r1.62 tree.tcl
--- tree.tcl	8 Sep 2009 20:46:40 -0000	1.62
+++ tree.tcl	9 Nov 2010 20:25:35 -0000
@@ -409,12 +409,12 @@
 	}
 
 	if { $data(upd,level) < 3 && $flag } {
-            if { [set idx [lsearch -exact $data(upd,nodes) $node]] == -1 } {
+	    array set n $data(upd,nodes)
+	    if {![info exists n($node)]} {
                 lappend data(upd,nodes) $node $flag
             } else {
-                incr idx
-                set flag [expr {[lindex $data(upd,nodes) $idx] | $flag}]
-                set data(upd,nodes) [lreplace $data(upd,nodes) $idx $idx $flag]
+		set n($node) [expr {$n($node) | $flag}]
+		set data(upd,nodes) [array get n]
             }
             _redraw_idle $path 2
         }