On Monday, June 30, 2014 12:21:07 PM UTC-5, Edward K. Ream wrote:
>
> On Mon, Jun 30, 2014 at 11:48 AM, 'Terry Brown' via leo-editor
> <[email protected]> wrote:
>
> > But even if the idle time was respected, are there really separate idle
> > times for each registered hook? Or just the first to init. idle time
> > events (which I think is in core) gets to specify the time?
> >
> > I'm not sure the arg. makes sense, unless the idle time hook firing
> > code's more sneaky than I think it is.
>
A recent rev revises idle-time handling as follows:
1. qtGui.setIdleTimeHook now uses a timer with a zero time count, which
should guarantee that it fires only at idle time::
def setIdleTimeHook (self,handler):
'''Queue up idle-time processing.'''
# Always define the callback so handler may be rebound.
<< define timerCallBack >>
if not self.timer:
self.timer = QtCore.QTimer()
self.timer.timeout.connect(timerCallBack)
# Fire the timer at idle time.
self.timer.start(0)
2. The timerCallback function guarantees that the idle-time callback (that
is, g.idleTimeHookHandler), never gets called more than once every
g.app.idleTimeDelay msec. This is important: it means that Leo won't be
overwhelmed with idle-time processing. Here is the code.::
def timerCallBack():
'''
The idle time callback.
Call handler, but never more than once every g.app.idleTimeDelay msec.
'''
if g.app.idleTimeHook:
# Idle-time processing is enabled.
t = time.time()
delta = t - self.last_timer_callback_time
delay = float(g.app.idleTimeDelay)/1000.0
if delta > delay:
self.last_timer_callback_time = t
# g.trace(delay,delta)
handler() # usually g.idleTimeHookHanlder.
elif self.timer:
# Idle-time processing is disabled. Stop the timer.
self.timer.stop()
As a result, the following script now toggles idle-time processing
properly, although to see it you should enable the g.trace(delay,delta) in
the callback::
if g.app.idleTimeHook:
g.disableIdleTimeHook()
else:
g.enableIdleTimeHook()
I think this resolves the original issues.
It seems to me, though, that g.enableIdleTimeHook should take *two*
arguments, instead of just the idleTimeDelay=500 argument as at present.
The second would be an override of g.idleTimeHookHanlder. For
compatibility, this should be the second keyword arg.
Unless I hear objections, I'll add this next.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.