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

Home » Public Forums » archive » Re: Unable to get the user value of the top level base after a draw widget expose event
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: Unable to get the user value of the top level base after a draw widget expose event [message #36115] Thu, 14 August 2003 20:03
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
I had this same problem for a while. You're event handler "checks-out"
the state variable (like a library book), and while it's checked-out,
some other event comes along looking for it.

If you take Pavel's advice and drop the /no_copy, you might run into a
problem in which two different routines are setting values of the
state and they may conflict or lose information somehow. You know that
there is some kind of conflict going on where two routines are already
reaching for the same state value.

The very best solution to all of this, a la Prof. Coyote, is to use a
pointer for the state. You don't need to change much, just instead of
state, the first time you set the uvalue use ptr_new(state, /no_copy).
Then every time you get the uvalue, you'll be getting a pointer to a
structure that only lives in memory once.

Your code becomes:
widget_control, event.top, get_uvalue = state
(*state).ThresOf = event.value

The line that re-sets the uvalue with state when you're done is no
longer necessary, since you never "checked it out."

In this way, multiple events _can_ access and interact with the state
with less fear of conflict.

One extra bit of advice. If *state is large, or you use many widgets,
you should make sure to clean up properly when the widget is killed.
Set a widget cleanup routine to free the pointer (if it's valid)
before destroying the widget and losing the pointer reference. You'll
avoid a potential memory leak.

I hope this helps.

M. Katz


Pavel Romashkin <pavel_romashkin@hotmail.com> wrote in message news:<3F3BAB5C.77984022@hotmail.com>...
> It seems you are losing your State structure. To check, get rid of
> /no_copy everywhere and try again. If it works, comb through your code
> and find where do you forget to put State back in. Typically this
> happens when you put your widget_control, event.top, set_uvalue = state,
> /no_copy in an IF statement that gets skipped in the code.
> Also, check if you don't forget to retrieve it in the pro in question.
> It should work just fine.
>
> Good luck,
> Pavel
>
Re: Unable to get the user value of the top level base after a draw widget expose event [message #36118 is a reply to message #36115] Thu, 14 August 2003 08:31 Go to previous message
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
It seems you are losing your State structure. To check, get rid of
/no_copy everywhere and try again. If it works, comb through your code
and find where do you forget to put State back in. Typically this
happens when you put your widget_control, event.top, set_uvalue = state,
/no_copy in an IF statement that gets skipped in the code.
Also, check if you don't forget to retrieve it in the pro in question.
It should work just fine.

Good luck,
Pavel

Johan Marais wrote:
>
> I keep on getting behaviour that I do not understand and as far as I
> understand it, should not happen. I use draw widgets and objects graphics
> with the EXPOSE_EVENTS from the draw widgets enabled. Here is an example:
>
> pro image_Expose, event
> widget_control, event.top, get_uvalue = state, /no_copy
> for i=0,7 do state.combWindow[i]->Draw, state.combView[i]
> widget_control, event.top, set_uvalue = state, /no_copy
> end
>
> pro setThresOf, event
> widget_control, event.top, get_uvalue = state, /no_copy
> state.ThresOf = event.value
> widget_control, event.top, set_uvalue = state, /no_copy
> end
>
> where image_Expose the event handler for the draw widget's expose event is.
> After a call to image_expose has been made and when I try to get the user
> value of the top level base, (for example in setThresOf) I receive the
> following error message:
>
> % Expression must be a structure in this context: STATE.
>
> When I issued the help statement, I receive the following:
> IDL> help, state, /STRUCT
> STATE UNDEFINED = <Undefined>
>
> It seems to me that the program are unable to get the top levels base user
> value once an expose event was executed.
>
> Did anyone ever come across this? I do not know whether any other part of
> the program can have an influence as well.
> --
> Johan Marais
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: setting the path for READ_DICOM
Next Topic: IDL does not work with new Linux Kernel; Anyone know why, or better solution?

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

Current Time: Fri Oct 10 02:33:54 PDT 2025

Total time taken to generate the page: 0.23551 seconds