| Ticket UUID: | 2790615 | |||
| Title: | [update] performs Tk callbacks in its own stack frame | |||
| Type: | Bug | Version: | obsolete: 8.5.7 | |
| Submitter: | danckaert | Created on: | 2009-05-12 12:15:02 | |
| Subsystem: | 69. Events | Assigned To: | jan.nijtmans | |
| Priority: | 8 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2020-06-08 15:27:28 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2020-06-08 15:27:28 | |||
| Description: |
The [update] command may cause certain callbacks to be executed at its own level in the call stack, not the global level.
The following script demonstrates the issue:
package require Tk
proc upd {level} {
# Perform an update somewhere deep in the call stack
if {[incr level -1] == 0} {update} else {upd $level}
}
pack [text .text -yscrollcommand {apply {args {puts [info level]}}}]
upd 7
This prints:
8
8
Note that this does not happen with [after idle] or [after $time] events, so it seems restricted to some specific Tk callbacks.
| |||
| User Comments: |
jan.nijtmans added on 2020-06-08 15:27:28:
OK, thanks! Merged to core-8-6-branch and trunk now. danckaert added on 2020-06-08 15:01:48: That commit indeed fixes it for me. Thanks, Jan and Francois, for taking this up! jan.nijtmans added on 2020-06-08 12:43:21: Koen, looking through it, indeed in a lot of places, the TCL_EVAL_GLOBAL was still missing. Please check this commit: [98094acacad82bc7], hopefully that fixes all of the remaining ones. Thanks for bringing this to our attention again! danckaert added on 2020-06-08 12:02:35: For me it still prints "8 8". (I also don't see TCL_EVAL_GLOBAL in the applied patch.) fvogel added on 2020-06-06 07:49:41: Thanks for this remark. Indeed you are right and this was never traced in this ticket: the patches posted here were superseded long ago by check-in [0deef053f6]. In more details, comparing patch "vareval2.patch" with [0deef053f6] I observe that all places where the patch makes changes are also changed by [0deef053f6] except in generic/ttk/ttkScroll.c (but changes there were made in [472e3798d1]). Moreover the example script (testing the case of the text widget only) prints ones (as expected) instead of eights. The only thing that remained to be done was updating some comments that still referred to Tcl_Eval, which I have now performed in [6ae2a28124]. As a result of all this I'm closing this ticket now, thanks again! chrstphrchvz added on 2020-06-06 04:17:32: The patches posted here were superseded long ago by check-in [0deef053f6]. I'm not sure if this issue was addressed by that check-in or if it is still present. hobbs added on 2009-05-20 07:53:42: I've updated the patch to not use any new functions. Please test _before_ and _after_ to make sure that I haven't caused any slightly adjustments in the test results. I found that listbox e.g. needed an extra (double) cast. Patch is against 8.5-head hobbs added on 2009-05-20 07:52:28: File Added - 327699: vareval2.patch hobbs added on 2009-05-20 07:50:43: File Deleted - 327697: hobbs added on 2009-05-20 07:19:15: File Added - 327697: vareval2.patch ferrieux added on 2009-05-13 22:59:47: In an attempt to preserve the readability ("a bit more tedious" is a bit scary), the attached patch just defines a MODULE_SCOPE vararg function TkVarGlobalEval doing exactly what Tcl_VarEval does but at global level.
This fixes the bug, and its generalization to the half-dozen other widgets with a similar shortcoming.
As explained in the function's comment, a Tk MODULE_SCOPE function is an interim position before promotion to a Tcl stub entry, but which works in between sync'ed Tcl and Tk releases. If there is a simple way to require the presence of a specific stub entry, then let's make it a Tcl stub entry directly.
ferrieux added on 2009-05-13 22:59:39: File Added - 326895: globaleval.patch hobbs added on 2009-05-12 22:45:20: I think we should just translate them to Tcl_EvalEx and skip all the older functions. This will make rewriting Tcl_VarEval calls a bit more tedious, but not that big of a deal. They might be made into Tcl_EvalObjEx and use the StringObj functions to build up the VarEval string. ferrieux added on 2009-05-12 22:25:48: More precisely, it would seem that: - buggy calls to Tcl_Eval should be turned into Tcl_GlobalEval - a new Tcl_GlobalVarEval should be invented (new stub entry ?) so change calls to Tcl_VarEval accordingly. - the code for Tcl_GlobalVarEval is trivial (just blend TGE and TVE). Do you agree Jeff ? ferrieux added on 2009-05-12 20:04:59: Ouch. As it turns out, this is linked to a whole bunch of Tk using the old-style Tcl_Eval/Tcl_VarEval API which has no way to specify TCL_EVAL_GLOBAL. Indeed the same bug occurs with all -*scrollcommand options of scrollable widgets. I'm ready to produce the patch, but Jeff do you see another way out ? | |||
Attachments:
- vareval2.patch [download] added by hobbs on 2009-05-20 07:52:28. [details]
- globaleval.patch [download] added by ferrieux on 2009-05-13 22:59:39. [details]
