Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2c2d2417c7266ba7ea6c3e217a8fa354d0ffafb8
Ticket: da15321a5852265331fcf94de655365551b9fa90
crash in variable traces when using itcl
User & Date: dgp on 2014-07-23 14:17:37
Changes

  1. icomment:
    Thanks to teo, here's a demo of the problem
    without use of Itk:
    
    package require Itcl 3
    
    itcl::class bar {
        public {
    	method config_textvar {w var} {
    	    $w configure -textvariable [itcl::scope $var]
    	    set $var [clock seconds]
    	}
        }
        private {
    	variable foo 0
    	variable bar 0
        }    
    }
    
    itcl::class foo {
        constructor args {
    	create
        }
    
        public {
    	method create {} {
    	    set obj_ [uplevel \#0 bar \#auto]
    	    pack [frame .f] -fill both -expand yes
    	    pack [button .f.a] [button .f.b] [button .f.c] [button .f.d] -fill both -expand yes
    	    switch -- $count_ {
    		0 {
    		    $obj_ config_textvar .f.a foo
    		    .f.b configure -textvariable [itcl::scope count_]
    		}
    		1 {
    		    $obj_ config_textvar .f.b foo
    		    .f.c configure -textvariable [itcl::scope count_]
    		}
    		2 {
    		    $obj_ config_textvar .f.c foo
    		    .f.a configure -textvariable [itcl::scope count_]
    		}
    	    }
    	    after $interval_ms_ [itcl::code $this assign]
    	}
    	method assign {} {
    	    incr count_
    	    if {$count_ > 2} { set count_ 0 }
    	    set foo_ $count_
    	    after $interval_ms_ [itcl::code $this remove]
    	}
    	method remove {} {
    	    rename $obj_ {}
    	    destroy .f
    	    unset foo_
    	    after $interval_ms_ [itcl::code $this create]
    	}
        }
        private {
    	variable interval_ms_ 100
    	variable count_ 0
    	variable foo_ 0
    	variable obj_ {}
        }
    }
    
    wm geometry . 200x200
    update idle
    foo .foo
    
  2. login: "dgp"
  3. mimetype: "text/plain"