widget cleanup problem [message #51686] |
Tue, 28 November 2006 10:59  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Hello,
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.
cheers,
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
|
|
|
Re: widget cleanup problem [message #51710 is a reply to message #51686] |
Tue, 05 December 2006 08:31  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Braedley writes:
> Why don't I ever see these simple solutions?
You are probably University-educated. Not your fault. :-)
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: widget cleanup problem [message #51711 is a reply to message #51686] |
Tue, 05 December 2006 08:23  |
Braedley
Messages: 57 Registered: September 2006
|
Member |
|
|
David Fanning wrote:
> Braedley writes:
>
>> My problem comes when I try to destroy the widget. I actually do make
>> it into the cleanup routine, but apparently label_base has already been
>> destroyed because I get the following error:
>> WIDGET_CONTROL: Invalid widget identifier: 0.
>> when I try to get the uvalue. I still want the user to be able to set
>> a uvalue for this compound widget, so setting the uvalue of base to
>> move_info won't work. Any suggestions?
>
> Now you are beginning to see one of the MAJOR reasons
> for writing all your compound widgets as objects. :-)
>
> But, here, just assign the CLEANUP (or even *another*
> CLEANUP) to the widget that actually has the pointer.
> There is no need to assign it to the compound widget
> TLB if there is nothing for it to do. :-)
>
> 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.")
Why don't I ever see these simple solutions? And I may eventually
convert this to an object, but I think creating my first compound
widget is good enough for now.
Thanks
Braedley
|
|
|
Re: widget cleanup problem [message #51713 is a reply to message #51686] |
Tue, 05 December 2006 08:10  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Braedley writes:
> My problem comes when I try to destroy the widget. I actually do make
> it into the cleanup routine, but apparently label_base has already been
> destroyed because I get the following error:
> WIDGET_CONTROL: Invalid widget identifier: 0.
> when I try to get the uvalue. I still want the user to be able to set
> a uvalue for this compound widget, so setting the uvalue of base to
> move_info won't work. Any suggestions?
Now you are beginning to see one of the MAJOR reasons
for writing all your compound widgets as objects. :-)
But, here, just assign the CLEANUP (or even *another*
CLEANUP) to the widget that actually has the pointer.
There is no need to assign it to the compound widget
TLB if there is nothing for it to do. :-)
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.")
|
|
|