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

Home » Public Forums » archive » Re: In catalyst, how do I decide which object need to be destroyed by hand?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: In catalyst, how do I decide which object need to be destroyed by hand? [message #67156] Thu, 02 July 2009 17:17
Dave[4] is currently offline  Dave[4]
Messages: 38
Registered: December 2007
Member
On Jul 3, 1:51 am, David Fanning <n...@dfanning.com> wrote:
> Dave writes:
>>   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?
>
> Well, you know me. I'm pretty anal.
>
> I don't think it is necessary. But after too many leaking
> memory mistakes on this newsgroup, I do tend to destroy
> everything alive when I exit a program. Follow my advice,
> not my example.  :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")- Hide quoted text -
>
> - Show quoted text -

Thanks very much! I have remove those "Obj_Destroy" lines, and no
leaking memory happen.
Re: In catalyst, how do I decide which object need to be destroyed by hand? [message #67161 is a reply to message #67156] Thu, 02 July 2009 10:51 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dave writes:

> 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?

Well, you know me. I'm pretty anal.

I don't think it is necessary. But after too many leaking
memory mistakes on this newsgroup, I do tend to destroy
everything alive when I exit a program. Follow my advice,
not my example. :-)

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
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 Go to previous message
Dave[4] is currently offline  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?
Re: In catalyst, how do I decide which object need to be destroyed by hand? [message #67167 is a reply to message #67162] Wed, 01 July 2009 08:49 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Interactive Debugging Tools
Next Topic: Re: Interactive Debugging Tools

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

Current Time: Wed Oct 08 15:15:47 PDT 2025

Total time taken to generate the page: 0.03173 seconds