Menu

#287 itcl::scope and itcl::configbody interaction: can't scope variable: missing object context

4.0*
open
nobody
None
5
2018-10-09
2018-10-09
No

The following script causes an error in 8.6 with Itcl 4.1.1, Iwidgets 4.0.

It appears to be a problem with using itcl::scope inside an itcl::configbody:

Error in startup script: can't scope variable "entryValue": missing object context
while executing
"itcl::scope entryValue"

And the configbody is signaled twice for some reason.

The code is pared down from our original code, and works just fine in Tcl 8.4, Itcl 3.2, Iwidgets 4.0.1

Also, a work around appears to be moving the body of entryMessageBox::choices into a different method, and calling the method from the configbody.

e.g. this works for some reason:

itcl::body entryMessageBox::choices_impl {} {
     # original implementation for choices, using [itcl::scope entryValue]
}
itcl::configbody entryMessageBox::choices {
   choices_impl
}

Code that reproduces the application error:

package require -exact Itcl 4.1.1
package require -exact Iwidgets 4.0

itcl::class entryMessageBox {
  inherit iwidgets::Dialog

  public variable entryValue {}
  public variable choices    {}

  constructor {args} {}
}

itcl::body entryMessageBox::constructor {args} {
  eval itk_initialize $args
}

itcl::configbody entryMessageBox::choices {
  itcl::scope entryValue
  # original use was something like this:
  # iwidgets::combobox [childsite].entry -textvariable [itcl::scope entryValue]
}

set dialog [entryMessageBox .browseCellDialog ]
$dialog configure -choices {CellA CellB CellC}

Discussion


Log in to post a comment.