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

Home » Public Forums » archive » How to cleanup an object with a non-modal widget method
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: How to cleanup an object with a non-modal widget method [message #88110 is a reply to message #88109] Thu, 20 March 2014 15:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Wayne Landsman writes:

> Thanks for this. I think that when destroying an object from a non-modal widget that IDL's automatic garbage collection does not come into play, so that one needs to have proper cleanup methods. And let's just say that my cleanup methods were, um, suboptimal, so it did not appear that the cleanup was working at all. My partial excuse is that automatic garbage collection has made me lazy, but I am also not entirely clear on the concepts.
>
> For example, my map display object includes many other objects which must either be created or passed in via keyword. So my INIT method looks like this:
>
> pro mapdisplay::init,oCoord=oCoord
> if obj_valid(oCoord) then self.oCoord = oCoord else self.oCoord = obj_new('Coord')
>
> Now in the cleanup method, I want to destroy self.oCoord if it was created in the ::INIT, but not if it was passed by keyword. How is the Cleanup method supposed to know which is the case? The only solution I can think of is to add a flag to the object, which can be used by ::CLEANUP
>
> pro mapdisplay::init,oCoord=oCoord
> if obj_valid(oCoord) then begin
> self.oCoord = oCoord
> self.destroy_oCoord = 0
> endif else begin
> self.oCoord = obj_new('oCoord')
> self.destroy_oCoord = 1
> endelse
>
> Is there a better way than this?

Not to my knowledge. This is the way I do it. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HOW TO COMPUTE BOUNDARY VALUES WHEN YOU HAVE TWO SPIKES IN YOUR DATA
Next Topic: IDL's BESELJ returns NAN for small argument and large order

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

Current Time: Sat Nov 29 14:00:22 PST 2025

Total time taken to generate the page: 0.48056 seconds