Re: How to cleanup an object with a non-modal widget method [message #88068 is a reply to message #88066] |
Mon, 17 March 2014 15:15   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
wlandsman writes:
> I have an object with a non-modal widget display method. While it is usually used in communication with other objects, I also want to have a simple wrapper to display the widget.
>
> pro displaymap
>
> oAstroMap = obj_new('AstroMap') ;Create the object
> oAstroMap.widgetdisplay ;Create the display widget
>
> return
> end
>
> While this works, it doesn't clean up after itself, leaving the heap area full. I can't put an OBJ_DESTROY statement before the RETURN because the non-modal widget doesn't wait for the widget to be destroyed, and executes the OBJ_DESTROY right away.
>
> I suppose what I want is for the widget to destroy the underlying object when one presses the Quit button. But my experiments with "OBJ_DESTROY, self " have not been successful.
I would write DisplayMap in such a way that you can get the object
reference back from it (write it as a function, or return the object in
a keyword). Then, I would just make sure I added the object reference to
the info structure of the widget program that calls it, and destroy
along with the other pointers and objects I was cleaning up in the
widget cleanup routine.
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.")
|
|
|