Re: Canceling or clearing TIMER events [message #55753] |
Fri, 07 September 2007 10:14 |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Sep 7, 9:38 am, David Fanning <n...@dfanning.com> wrote:
> M. Katz writes:
>> The IDL Help explanation of CLEAR_EVENTS isn't clear enough to say
>> whether it applies in this case. I can envision a case where the user
>> closes the widget, and then the event arrives all dressed up with
>> nowhere (no valid widget IDs) to go.
>
> I would guess this is what happens. CLEAR_EVENTS will clear
> events that are on the event queue, but your timer event hasn't
> been dispatched to the queue yet, so it can't be cleared.
>
> I'd say you will probably have to put a KILL_NOTIFY on
> your TLB and delay destroying the widget until that last
> timer event shows up.
>
> Cheers,
>
> David
>
> P.S. Of course, there is always the chance that IDL is
> smart enough to NOT send the timer to a widget that
> doesn't exist, but I would think the chance is vanishingly
> small. :-)
In my simple test case below, it seems like IDL is smart enough not to
send an event to widget that doesn't exist. At least I get no error
messages when I kill the widget between events (i.e. with an event
still "out there"). Did you just want to clean up properly or was
there something you need to do with that event?
pro test_event, event
print, 'Got event'
widget_control, event.id, timer=5.0
end
pro test
tlb = widget_base(/column)
draw = widget_draw(tlb)
timer = widget_base(tlb, uname='timer')
widget_control, tlb, /realize
widget_control, timer, timer=5.0
xmanager, 'test', tlb
end
Mike
--
www.michaelgalloy.com
|
|
|
Re: Canceling or clearing TIMER events [message #55756 is a reply to message #55753] |
Fri, 07 September 2007 08:38  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
M. Katz writes:
> The IDL Help explanation of CLEAR_EVENTS isn't clear enough to say
> whether it applies in this case. I can envision a case where the user
> closes the widget, and then the event arrives all dressed up with
> nowhere (no valid widget IDs) to go.
I would guess this is what happens. CLEAR_EVENTS will clear
events that are on the event queue, but your timer event hasn't
been dispatched to the queue yet, so it can't be cleared.
I'd say you will probably have to put a KILL_NOTIFY on
your TLB and delay destroying the widget until that last
timer event shows up.
Cheers,
David
P.S. Of course, there is always the chance that IDL is
smart enough to NOT send the timer to a widget that
doesn't exist, but I would think the chance is vanishingly
small. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|