Tk Library Source Code

Artifact [ea84303b2a]
Login

Artifact ea84303b2a61d6ef3e89b030c2f30323f4844630:

Attachment "treetst2.tcl" to ticket [1528614fff] added by hgiese 2006-07-26 03:28:10.
#
# Trying to create a test script for the tree package's failure.
# This happens with Tcl 8.4.13 using the 'criticl' version of struct::tree
# (under Win98, but I doubt that this matters).
#
# It does NOT happen with 8.4.91 and (with 8.4.13) it does NOT happen with
# the pure Tcl version of struct::tree.
#

package require struct::tree

# Write $s to $fName
proc strToFile {fName s} {
    set fd [open $fName w]
    puts -nonewline $fd $s
    close $fd
}

set tree1 [::struct::tree]
# create a node
set node [$tree1 insert root end]
# save and delete the tree
set content1 [$tree1 serialize]
strToFile tree1.txt $content1
$tree1 destroy

# use the content of tree1 to create another tree
set tree2 [::struct::tree]
$tree2 deserialize $content1
# create another node --- tree2's root will now have 2 children
set node [$tree2 insert root end]
# save and delete the tree
strToFile tree2.txt [$tree2 serialize]
$tree2 destroy      ;# BOOM

# If you look at file tree2.txt you will notice that root does have 2 children
# now BUT BOTH are named 'node1'.