|
2008-04-10
| ||
| 22:39 | • Ticket [219268ffff] Catching errors at vwait instead of bgerror status s... artifact: 647fb88285 user: ferrieux | |
| 22:14 | • Ticket [219268ffff]: 4 changes artifact: d6739fc2d0 user: dgp | |
| 14:50 | • Ticket [219268ffff]: 4 changes artifact: 50753d10e0 user: ferrieux | |
| 04:56 | • Ticket [219268ffff]: 4 changes artifact: f9366638f4 user: nobody | |
| 04:28 | • Ticket [219268ffff]: 4 changes artifact: 2ef20afdf0 user: ferrieux | |
|
2003-11-13
| ||
| 06:08 | • Ticket [219268ffff]: 1 change artifact: 98ecba845d user: dgp | |
|
2001-04-04
| ||
| 04:42 | • Ticket [219268ffff]: 1 change artifact: 1d19d13344 user: dgp | |
|
2001-02-07
| ||
| 23:13 | • Ticket [219268ffff]: 1 change artifact: 5433e6c43c user: dkf | |
|
2000-11-19
| ||
| 18:09 | • Ticket [219268ffff]: 7 changes artifact: bd8459b1a1 user: dkf | |
|
2000-10-26
| ||
| 05:09 | • New ticket [219268ffff]. artifact: 3a3e1fabad user: nobody | |
Catching errors at [vwait] instead of [bgerror]
Open219268ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 19 years ago
Descriptionplain2000-10-26 05:09:39
OriginalBugID: 1347 RFE
Version: 8.0.4
SubmitDate: '1999-03-02'
LastModified: '1999-03-02'
Severity: SER
Status: UnAssn
Submitter: pat
ChangedBy: pat
OS: Other
OSVersion: All OSes
Machine: NA
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'
Name:
Alexandre FERRIEUX
DesiredBehavior:
Currently, when an error occurs in an event/after handler, it is handled
by the bgerror mechanism: the info about error is saved, and an [after
idle]
is posted to pop up an error dialog later. Note that all this doesn't
interrupt
the surrounding [vwait]. This is fine for normal wish apps using the
implicit
Tk event loop
In more complex situations, the [vwait] is called by the programmer, and
it
would be preferable that the errors be raised synchronously, i.e. they
interrupt
the vwait. This way a [catch] of the vwait will do the right thing. For
backward
compatibility, this new behavior could be activated by an option [vwait
-errors], or by a global variable [set ::tcl_vwait_errors 1].
Of course, a workaround currently exists, but it is inelegant and
inefficient:
proc bgerror s {set ::_bgerror_var BGERROR:$s}
proc vwait_e vvar {
upvar #0 $vvar ::_bgerror_var
vwait ::_bgerror_var
if {[regexp {^BGERROR:(.*)$} $::_bgerror_var pipo res]} {error $res}
return $::_bgerror_var
}
(The problem with this is that if you don;t want to wipe out an already
defined
bgerror, you have to switch it back and forth with [rename]. If you have
to do
this frequently, the performance is terrible.)
dkfplain2000-11-19 18:09:15
I'm in two minds about this; though it is functionality which is useful in some situations, it also disturbs the currently defined behaviour of errors that occur in an event. But I suppose that's the whole point! :^)
One way of doing it might be to make vwait take an optional extra argument (after the name of the global variable) that specifies an alternate error handler to use in place of bgerror for the duration of the wait (so you could avoid the expense of renaming commands all over the place.) Or maybe do it like this (using slightly more acceptable syntax):
vwait -errorhandler someProcedure someGlobalVariable
The only complication comes when you have loads of nested vwaits, but that is a situation that is pretty nasty anyway even without wanting to do several different error handlers...
dkf Ticket [219268ffff]: 1 change
[History diff]2001-02-07 23:13:30
dgp Ticket [219268ffff]: 1 change
[History diff]2001-04-04 04:42:32
dgp Ticket [219268ffff]: 1 change
[History diff]2003-11-13 06:08:20
ferrieuxplain2008-04-10 04:28:00
Logged In: YES
user_id=496139
Originator: NO
OK, an explicit option is the way to go.
But instead of passing a callback, why not just raise a synchronous exception ?
vwait -syncerr var
The idea is that catching the vwait (or one of its callers, unaware of the underlying vwait, like in http) is a more modular idiom than defining an extra procedure.
nobodyplain2008-04-10 04:56:13
Logged In: NO What would the proposed '-syncerr' option mean, exactly?
ferrieuxplain2008-04-10 14:50:26
Logged In: YES
user_id=496139
Originator: NO
The idea is that
after 0 {error yo}
vwait -syncerr forever
would raise "yo" instead of installing an idle handler calling bgerror.
Thus we'd support the isolated uses of [vwait] with none of the current ill-effects reported on this clt thread:
http://groups.google.com/group/comp.lang.tcl/browse_frm/thread/3e178c574d6341fb/3303ebcc6767ec3d#3303ebcc6767ec3d
And since it's an option, it won't risk any incompatibility for single-vwait and Tk-based apps, as per Donal's suggestion.
dgpplain2008-04-10 22:14:59
Logged In: YES user_id=80530 Originator: NO As I understand it, the complaint is about the practice of Tcl_BackgroundError() to arrange for the background error handling command to be evaluated as an idle callback via a Tcl_DoWhenIdle() call. Or perhaps that various Tcl_EventProcs call Tcl_BackgroundError() in the first place. These routines are not directly attached to the [vwait] command. They generally that operate in any event loop. As such it seems a mismatch to me to try to influence the behavior of general client routines of the notifier infrastructure with an option to only one of the event loop creating commands in only one of the interps the notifier may be managing events for. There may still be a problem here worth addressing (not convinced either way), but I don't think a correct path for addressing it has been identified.
ferrieuxplain2008-04-10 22:39:47
Logged In: YES
user_id=496139
Originator: NO
It is true that the various callbacks call Tcl_BackgroundError() which does two things:
- enqueue the error in a linked list in assocdata("tclBgError")
- if not done yet, Tcl_DoWhenIdle(HandleBgErrors)
My naive idea was, in presence of [vwait -syncerr], to directly test the non-emptiness of that linked list at each at each turn of the vwait loop, and to directly return from [vwait] with the proper TCL_ERROR and associated error string computed from what's stored in the first cell of the list (BTW I don't know in what situations this list could be longer than 1).
So, this would only affect the one vwait that has the flag, and would do so without non-local influence on the behavior of the general client routines like Tcl_BackgroundError() et al.
Or am I missing something ?
Log in (anonymous is fine) to add a comment.