comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Event handling stops for no reason?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Event handling stops for no reason? [message #69977] Thu, 04 March 2010 09:36
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
> I have confirmation from one of my always reliable sources
> that there has been a bit of a timer issue introduced
> in IDL 7.0 and 7.1. Basically, this kind of thing can
> occur unless there is a short delay between handling one
> timer event and sending the next.

I learned this the hard way early last year, when I had written a
movie player. I had the same phenomenon, that it would play only when
I moved the mouse over the widget area.

However, this time, I am not using any timer events. I just inserted
some temporarily, and in this case they actually seemed to resolve the
problem.

Cheers,
Michael
Re: Event handling stops for no reason? [message #69978 is a reply to message #69977] Thu, 04 March 2010 08:36 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Sometimes things happen faster than you can think, or not.
> I have, on occasion, put a Wait, 0.1 into my code to slow
> things down a bit. This seems to be a timing issue now.

I have confirmation from one of my always reliable sources
that there has been a bit of a timer issue introduced
in IDL 7.0 and 7.1. Basically, this kind of thing can
occur unless there is a short delay between handling one
timer event and sending the next. Normally, some small
amount of processing before the next event is sent is
enough to put things right (that is, put the next timer
event at end of the event handler, not at the top).
Sometimes you might need to slow things down a bit with
a Wait statement.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: Event handling stops for no reason? [message #69980 is a reply to message #69978] Thu, 04 March 2010 08:09 Go to previous message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
> Sometimes things happen faster than you can think, or not.
> I have, on occasion, put a Wait, 0.1 into my code to slow
> things down a bit. This seems to be a timing issue now.
Yep, I have frequently used this for loops which otherwise took ages
to complete. However, in this case, it did not help...

I was able to reproduce the behavior several times now. The program is
really in a state of not doing anything. It is not stuck at a line of
code.
When I interrupt processing using this little red square (Cancel? Have
a German IDL version), the GUIs are closed and the program terminated.
IDL does not jump to a line in my code like it usually would. It
really seems that the event is hanging around somewhere? And the
program is supposed to automatically process a large number of files
over night...
I experimented with timer events to wake up IDL. That seemed to work.
More mysteries...

As this was so totally annoying, I now modified the code and send the
"event" directly (main module's object ID stored in group leader's
uValue):
Widget_Control, self.Group_Leader, Get_uValue = AviStack2
AviStack2->Event, {Processing, 0L, 0L, 0L, ok, self.preset}

I had to modify the code of my main module only slightly and
substituted the send_event in about 20 objects... I don't really like
it this way. But, it is working!

> P.S. Have you ever thought maybe this program design
> was *too* clever? ;-)
This is so spot on :-)))

Thanks for your help!
Michael
Re: Event handling stops for no reason? [message #69992 is a reply to message #69980] Wed, 03 March 2010 16:48 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MichaelT writes:

> This is not regularly reproducible... Sometimes it works for several
> steps only to stop again.

Sometimes things happen faster than you can think, or not.
I have, on occasion, put a Wait, 0.1 into my code to slow
things down a bit. This seems to be a timing issue now.

Cheers,

David

P.S. Have you ever thought maybe this program design
was *too* clever? ;-)

--
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.")
Re: Event handling stops for no reason? [message #69993 is a reply to message #69992] Wed, 03 March 2010 16:29 Go to previous message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
Now I was finally able to reproduce it again. It is not the send_event
= {info...} but the second send_event that I use.

This is what happens:

I initiate the program via an event. Within the event handler of the
main program the sub-program is started and does the following:

Print '1'

Widget_Control, self.Group_Leader, Send_Event = {Info, 0L, 0L, 0L,
(*self.lang).info}

(then I let the event handler print the info text)

Print '2'

...
some calculations
...

Print, '4'
self->Finished, 1
Print, '5'
Return


self->Finished, 1 does the following (and only this):

Widget_Control, self.Group_Leader, Send_Event = {Processing, 0L, 0L,
0L, ok, self.preset}

{Processing} is defined as:
void = {Processing, ID: 0L, Top: 0L, Handler: 0L, ok: 0, preset: 0}

It sends an event to the event handler of the main program.

IDL prints 1, info text, 2, ..., 4 and 5, so I assume the event is
sent.

The next processing step is not initiated which has the same structure
as the previous one. The info label is not updated (I said so
otherwise, before, sorry) and the next "1" is not printed. Only when I
move the mouse onto the GUI does IDL resume processing and print the
1, ...

This is the chain of events (also judging from what IDL prints:

1. First step finished, send event to event handler.
2. Enters event handler, maps GUI and does what I have written above
(basically all done within event handler).
3. Prints "1"; GUI sends event to update label (works); prints label
text.
4. Prints "2" through "4"
5. GUI sends event to initiate another GUI.
6. Prints "5"
7. Leaves event handler.
8. Processes next event in cue.
9. Should now map next GUI and print "1", label text, "2" ... Does not
do that.

This is not regularly reproducible... Sometimes it works for several
steps only to stop again.

Cheers,
Michael
Re: Event handling stops for no reason? [message #69996 is a reply to message #69993] Wed, 03 March 2010 15:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MichaelT writes:

> Yes. Like this:
>
> ;Get the structure name of the event
> Case Tag_Names(ev, /Structure_Name) Of
>
> ;Tell the user what to do. Event is generated when an object is
> mapped/started.
> 'INFO': Begin
> Widget_Control, self.info, Set_Value = ev.info
> Return
> End

You say "processing stops". But what else
would you expect to happen if you set the value of
a widget? Is this an event-driven application?
Maybe "setting the value" needs to fire off another
event to get the next processing step started.

Cheers,

David



--
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.")
Re: Event handling stops for no reason? [message #69997 is a reply to message #69996] Wed, 03 March 2010 15:47 Go to previous message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
> Well, you don't tell me how {INFO} is defined,

void = {Info, ID: 0L, Top: 0L, Handler: 0L, Info: ''}

This should be OK.

> but if it is not defined with an ID, TOP, and HANDLER
> field, then it is likely this event is being swallowed
> in the event handler of the self.group_leader widget.
> Is that the event handler that is suppose to do something
> sensible with this event?
Yes. Like this:

;Get the structure name of the event
Case Tag_Names(ev, /Structure_Name) Of

;Tell the user what to do. Event is generated when an object is
mapped/started.
'INFO': Begin
Widget_Control, self.info, Set_Value = ev.info
Return
End
...

This is indeed executed and then processing stops until I move the
mouse. There are no further events involved...

>
> Just too many unknowns here for me to make sensible
> judgments.
I am afraid so.

I just had the hope this was some known phenomenon.

Thanks for your help anyway!

Michael
Re: Event handling stops for no reason? [message #69998 is a reply to message #69997] Wed, 03 March 2010 15:01 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MichaelT writes:

> I have an object which sends an event to the main program to update an
> info label (to tell the user what the sub-program is currently doing):
> Widget_Control, self.Group_Leader, Send_Event = {Info, 0L, 0L, 0L,
> (*self.lang).info}

Well, you don't tell me how {INFO} is defined,
but if it is not defined with an ID, TOP, and HANDLER
field, then it is likely this event is being swallowed
in the event handler of the self.group_leader widget.
Is that the event handler that is suppose to do something
sensible with this event?

Just too many unknowns here for me to make sensible
judgments. Maybe you want to send this event to the
draw widget?

Cheers,

David



--
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.")
Re: Event handling stops for no reason? [message #69999 is a reply to message #69998] Wed, 03 March 2010 14:42 Go to previous message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
Here is a more detailed description of what I do:

I have an object which sends an event to the main program to update an
info label (to tell the user what the sub-program is currently doing):
Widget_Control, self.Group_Leader, Send_Event = {Info, 0L, 0L, 0L,
(*self.lang).info}

The structure Info is defined in the main program's object definition.

This event is indeed sent, at least the line before the command is
executed which I checked via some "print something" commands + the
label is updated.
However, processing then, sometimes, stops (I think I did not get that
exactly right in my previous post). The weird thing is, it almost
always works. And processing continues as soon as the mouse cursor
enters any place of the GUIs area (not a draw widget). It looks like
the process falls asleep and then awakes as soon as the mouse moves
onto the GUI. When I move the mouse around the desktop and not onto
the GUI, nothing happens.

> I don't know. Maybe you are assuming the event gets
> consumed as soon as it gets queued. Are you using
> the normal XManager event handling?
Yes, I use the xManager.

> Maybe you are
> assuming that if the event gets consumed it automatically
> fires off the next event. Have you stepped though the
> code from the time the event appears in the event handler
> to confirm this?
The label is updated, but, processing does not resume (no further
events involved) unless you move the mouse as described above.

> I just think the chance of it being anything but
> a programming error is very small. I don't know
> which of your programming assumptions is faulty,
> but I'd be some money one of them is.
I believe so, too. I'd very much like to know what it is.

In the mean time I have modified the code as follows:

Widget_Control, self.Group_Leader, Get_uValue = main
main->Event, {Info, 0L, 0L, 0L, (*self.lang).info}

This seems to work. I now get around xManager. I can live with that,
but, would still like to know the cause...

Cheers,
Michael
Re: Event handling stops for no reason? [message #70000 is a reply to message #69999] Wed, 03 March 2010 14:10 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MichaelT writes:

> So, what would be the faulty assumption then? What should I be looking
> for?

I don't know. Maybe you are assuming the event gets
consumed as soon as it gets queued. Are you using
the normal XManager event handling? Maybe you are
assuming that if the event gets consumed it automatically
fires off the next event. Have you stepped though the
code from the time the event appears in the event handler
to confirm this?

I've seen silent error handlers show symptoms like
this. :-)

I just think the chance of it being anything but
a programming error is very small. I don't know
which of your programming assumptions is faulty,
but I'd be some money one of them is.

Cheers,

David


--
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.")
Re: Event handling stops for no reason? [message #70003 is a reply to message #70000] Wed, 03 March 2010 12:22 Go to previous message
MichaelT is currently offline  MichaelT
Messages: 52
Registered: May 2006
Member
>
> I'm going to guess faulty assumptions leading to
> bad programming practices, but that's only a guess. :-)

So, what would be the faulty assumption then? What should I be looking
for?

Thanks,
Michael
Re: Event handling stops for no reason? [message #70005 is a reply to message #70003] Wed, 03 March 2010 11:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
MichaelT writes:

> I have some quite strange behavior with a GUI.
>
> Basically, event handling stops for seemingly no obvious reason. It is
> resumed as soon as I move the mouse cursor over the GUI area. The
> event which is in the cue, is then executed immediately.
> It is quite a complex program which processes images and sends an
> event to the event handler as soon as a certain step is finished. The
> next processing step should then be initiated by this event. But, it
> simply stops until I move the mouse, as described above.
> I was unable to find a cause for such behavior. From what I have
> figured out, this does not occur when the mouse cursor is permanently
> over the GUI.
>
> Any idea what could be causing this?

I'm going to guess faulty assumptions leading to
bad programming practices, but that's only a guess. :-)

Cheers,

David


--
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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: to read and to save multiple fits format files at a time
Next Topic: idlwave completion does not work

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:08 PDT 2025

Total time taken to generate the page: 0.41467 seconds