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

Home » Public Forums » archive » Re: widget cleanup problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: widget cleanup problem [message #51682 is a reply to message #51681] Tue, 28 November 2006 11:52 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul van Delst writes:

> I'm having a bit of issue with cleaning up after myself in a widget program.
>
> I have a main GUI that, alongside "regular widgets" also contains a bunch of standalone
> compound widgets. The main GUI info structure and loading looks something like:
>
> Info = { Debug : Debug , $
> cw1Id : cw1Id , $ ; compound widget 1 base id
> cw2Id : cw2Id , $ ; compound widget 2 base id
> cw3Id : cw3Id , $ ; compound widget 3 base id
> .....etc....
> cwNId : cwNId } ; compound widget N base id
> InfoPtr = PTR_NEW( Info )
> WIDGET_CONTROL, tlBaseId, SET_UVALUE = InfoPtr
>
> To get a look at the compound widgets info structure I do the following:
>
> WIDGET_CONTROL, Info.cw3Id, GET_UVALUE = cw3_InfoPtr
>
> My problem is that when an exit event occurs and the cleanup routine is called, the child
> compound widgets are cleared first so the reference to their top-level-based is gone and I
> now have dangling pointers.
>
> In my main "exit" event handler, all the various compound widget base ids are still valid.
> However, by the time the "cleanup" routine is called, they are not -- and thus I can't
> free the info pointers.
>
> I wanted the main "cleanup" routine to handle all the child compound widget pointer
> free'ing. Does it *have* to be done in the main "exit" event handler?
>
> I hope my explanation above makes sense.

People here are just entirely too optimistic today!

With these kind of compound widgets, what we usually do
is use KILL_NOTIFY to assign a callback to the TLB of the
compound widget. (This isn't really a TLB, but you know
what I mean.) When that base widget dies, you enter your
"cleanup" routine for that compound widget. (This means
you will have to write one for it.) This is where you
free your pointer.

This is *identical* to the CLEANUP routine you assign to
the application's TLB, except that you can't (supposedly)
use KILL_NOTIFY to assign a cleanup routine to a widget that
is being managed directly by XManager. You have to use the
CLEANUP keyword on XManager. (I see ITTVIS programmers break
this rule all the time, so I presume it's not enforced like
it used to be, but I still teach it this way. And it still
works.)

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.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Logarithmic Color Scaling
Next Topic: widget cleanup problem

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

Current Time: Wed Dec 03 01:02:07 PST 2025

Total time taken to generate the page: 0.31806 seconds