| Ticket UUID: | 793909 | |||
| Title: | Problem with nonexistent namespaces | |||
| Type: | Bug | Version: | obsolete: 8.5a0 | |
| Submitter: | lcargill | Created on: | 2003-08-23 21:43:46 | |
| Subsystem: | 07. [entry] | Assigned To: | fvogel | |
| Priority: | 6 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2015-12-19 23:16:54 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2015-12-19 23:16:54 | |||
| Description: |
Platform:
Win98SE,Wish8.3for Windows.
Description:
It is possible to assign the "-textvariable <name>" option
to an entry widget using a namespace that does not
yet exist.
After the namespace and variable are instantiated, changes to
the variable are not reflected within the text widget.
Subsequent ".entry config -textvariable <name> "
commands do not clear up the problem.
Code snippet:
entry .foo -textvariable fred::foo(wha)
namespace eval fred {
variable foo
}
grid .foo
set fred::foo(wha) "Hey!"
| |||
| User Comments: |
fvogel added on 2015-12-19 23:16:54:
Fix merged in core-8-5-branch and trunk. fvogel added on 2015-12-12 16:04:10: Answering my own question (Is it desirable to return an error when attempting to link an entry or spinbox textvariable to a variable that lives in a non-existing namespace?): Yes it is. ttk::entry does it. Fix now proposed in branch bug-793909fff. fvogel added on 2015-12-11 16:56:59: What could be done until TIP#277 gets implemented is to return an "unknown namespace" error when configuring the entry with -textvariable pointing to a variable that could not be created.
This would never trigger for variables pertaining to existing namespaces (variables there are created as needed), only for variables created in namespaces that do not (yet) exist.
Question is: is this desirable?
Especially since this statement from the OP:
"After the namespace and variable are instantiated, changes to
the variable are not reflected within the text widget."
does not seem to be correct to me, as evidenced by the following example:
package require Tk
entry .foo -textvariable fred::foo(wha)
namespace eval fred {variable foo}
grid .foo
set fred::foo(wha) "Hey!"
# The entry does not show "Hey!" because the textvariable did not exist when
# setting -textvariable
# Now (contrary to what the OP seems to state):
.foo configure -textvariable fred::foo(wha)
# now the entry correctly shows "Hey!"
Opinions please?
dgp added on 2003-10-07 04:35:54: Logged In: YES user_id=80530 It appears that the [entry] code was written with the assumption that Tcl_SetVar() always succeeds in creating a variable, and Tcl_TraceVar always succeeds in creating a trace. Those calls do not automatically create missing namespaces, so they actually fail when directed to work on a variable in a namespace that does not (yet) exist. The workaround, of course, is to create namespaces before tying widgets to them. An actual fix has to wait until a time when Tcl might be modified to create namespaces as they are needed. See Tcl RFE 582926. That will not happen in an 8.4.x release. dgp added on 2003-10-07 04:04:03: Logged In: YES user_id=80530 confirmed in 8.4x and HEAD Looks like it may really be a bug in variable traces. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki