From: Michael B. <tc...@ba...> - 2011-02-18 09:51:22
|
Hello everybody, if you inherit from a class with the same name, but from a different namespace, the destructor of that class will never be reached!!! Here is my code: puts "\[incr Tcl\] [package require Itcl]" namespace eval a {} namespace eval b {} itcl::class a::A { destructor { puts a::A\t[info heritage] } } itcl::class b::A { inherit a::A destructor { puts b::A\t[info heritage] } } itcl::class b::B { inherit a::A destructor { puts b::B\t[info heritage] } } foreach class {b::B b::A} { set obj [$class #auto] puts ------------------$obj\ ($class)\ --- itcl::delete object $obj puts "" } and here the output: [incr Tcl] 3.2 ------------------b0 (b::B) --- b::B ::b::B ::a::A a::A ::a::A ------------------a0 (b::A) --- b::A ::b::A ::a::A This is a bug in [incr Tcl], but you can avoid it: Don't name your class with a one of the class name of the [inherit] command!!! Does itcl-ng also has this bug? Can anybody check this? Regards Michael |