On Thu, 22 May 1997, Troy Monaghen wrote:
> Today I opened a moderately sized vtcl application and proceeded to add
> another toplevel widget... but it was not until I saved it (I was actually
> going for "Save As..." but accidentally hit "Save") that I noticed that it
> named the toplevel widget the same as a previous one ".top19" and overwrote
> the previous one.  Any ideas what might cause this to happen or how to
> avoid this in the future??? Should I turn off the automatic naming and
> manually give names to all my widgets?

There was a bug in an internal procedure (vTcl:diff_list) that showed up
very rarely.  It caused just this behavior in my application too.  I
believe this will be fixed in vtcl 1.10.

If you can't wait, apply the attached patch.

Regards,
--
Kenneth H. Cox
Software Guy
Sente, Inc.

--- vtcl-1.09/lib/misc.tcl      Sun Apr  6 03:56:43 1997
+++ vtcl/lib/misc.tcl   Wed May 21 13:24:13 1997
@@ -66,31 +66,16 @@
     return $nlist
 }
 
+# kc: new faster diff_list.  Returns list containing only those elements
+# in $newlist that don't exist in $oldlist.
 proc vTcl:diff_list {oldlist newlist} {
     set output ""
-    set index 0
-    set oldlist2 [lsort $oldlist]
-    set oldlen [llength $oldlist2]
-    set newlen [llength $newlist]
-    foreach i [lsort $newlist] {
-        while { 1 } {
-            if { $index > $oldlen } {
-                lappend output $i
-                break
-            }
-            set result [string compare $i [lindex $oldlist2 $index]]
-            if { $result == -1 } {
-                lappend output $i
-                break
-            } elseif { $result == 0 } {
-                incr index
-                break
-            } else {
-                incr index
-                if { $index > $oldlen && $index > $newlen } {
-                    break
-                }
-            }
+    foreach oldent $oldlist {
+        set oldar($oldent) 1
+    }
+    foreach newent $newlist {
+        if {[info exists oldar($newent)] == 0} {
+            lappend output $newent
         }
     }
     return $output

Reply via email to