Re: In catalyst, how do I decide which object need to be destroyed by hand? [message #67162 is a reply to message #67161] |
Thu, 02 July 2009 09:56   |
Dave[4]
Messages: 38 Registered: December 2007
|
Member |
|
|
On Jul 1, 11:49 pm, David Fanning <n...@dfanning.com> wrote:
> Dave writes:
>> In catalyst, how do I decide which object need to be destroyed by
>> hand? Because I find some objects, such as ButtonWidget, can destroy
>> itself. But others, such as SelectableDrawWidget and IMGAXES, need to
>> destroyed in cleanup procedure. Thanks very much!
>
> You must be writing your Catalyst programs differently
> than I am. :-)
>
> I don't find that *any* of the Catalyst objects need
> to be destroyed by hand, if they are properly added to
> the widget container hierarchy as they are created.
> (The top of any Catalyst program I build is a TopLevelBase
> object.)
>
> If you are creating an object that is going to have
> a "has a" relationship to a Catalyst object, the object
> must register interest in the Catalyst object by making
> itself the parent of the Catalyst object. Then, in your
> cleanup method, you simply remove yourself as the parent
> of the Catalyst object. If this is the only parent, the
> Catalyst object should be destroyed automatically.
>
> Perhaps you can give me some indication of how you are using
> these objects that aren't cleaning themselves up.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
David:
I read your imgwin example. There are following code:
PRO ImgWin::CLEANUP
@cat_pro_error_handler
IF Obj_Valid(self.theImage) THEN self.theImage -> RemoveParent,
self
Obj_Destroy, self.theDrawWidget
Obj_Destroy, self.theAxes
Obj_Destroy, self._statusbar
self -> TOPLEVELBASE::Cleanup
self -> Report, /Completed
END
So I think that you destroy self.theDrawWidget, self.theAxes and
self._statusbar by hand. Am I right?
|
|
|