Tk Library Source Code

View Ticket
Login
Ticket UUID: 3106208
Title: tree itemconfigure mishandling of node names
Type: Bug Version: None
Submitter: andreas_kupries Created on: 2010-11-09 20:30:54
Subsystem: bwidget Assigned To: oehhar
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-12-15 00:05:15
Resolution: Fixed Closed By: oehhar
    Closed on: 2010-11-10 08:00:25
Description:
The original description, as submitted to ActiveState:
========================================
I am currently using version 1.8 of the BWidget library. I have found an  error (or lack of documentation) in the Tree library. I am using the tree structure in my software to display connections between devices. Each node in  my tree is named using the unique ID of the device which the tree node represents (these are integer values). When doing an "itemconfigure" in my code I run into an error. The error is caused by using integer values for node names. The error is described below.

In the code section (below) taken from Tree::itemconfigure there exists a case when a node name is the same value as a flag value (in my system I had a node named 16 and a flag value that turned out to be 16). When doing the lsearch to find the idx of the node, the search finds the index of the flag value 16 (and assumes this is the node). When it does the incr to get the corresponding flag value it is really picking up a node name. In my system I also have node names that are strings. In my case the code was picking up a node name that was a string and when trying to set the flag it was doing an "|" with a flag value and a string (which causes Tcl to crash).

 if { $data(upd,level) < 3 && $flag } {
      if { [set idx [lsearch -exact $data(upd,nodes) $node]] == -1 } {
         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]
      }

I do not see any documentation stating that node names cannot be integer values. As a result, I deem this to be a bug that should be addressed.
If you are not the people who deal with Tcl bug, please pass this on to the people who fix bugs. Thanks.
========================================

My fix for the problem is attached.
User Comments: andreas_kupries added on 2010-12-15 00:05:15:

File Added - 396097: tree-tcl.patch

oehhar added on 2010-11-11 15:00:22:
Dear Dlittau,
thank you for the report and the test. That is good news.
I plan a bugfix release in december (see wiki.tcl.tk/bwidget)

dlittau added on 2010-11-11 01:06:31:
oehhar, do you know in which release this fix will be included? Is there an upcoming release of the BWidget library? I am going to take your patch and include it in my source code (overwrite the BWidget 1.8 tree::itemconfigure method with the new patched) so that my code will function. Just wondering when this patch will be included into an official release.

dlittau added on 2010-11-11 00:47:56:
I was the one who sent this Bug to ActiveState. I took the patch code and tested it in my system. Seems to work. The error I reported no longer exists.

oehhar added on 2010-11-10 15:00:24:
Hi Andreas,
thank you for the report and fix. It looks good and is in cvs now.

I wouldn't mind to have an example which shows the issue (I am to lazy to make one).

andreas_kupries added on 2010-11-10 03:30:55:

File Added - 392697: bwidget-tree.patch

Attachments: