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

Home » Public Forums » archive » Re: Catalyst CatDestroyDefaults
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: Catalyst CatDestroyDefaults [message #66978] Sun, 28 June 2009 07:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> It is probably appropriate that this comes on the heels of
> another discussion a week or so ago about the inability of
> UNDEFINE to undefine everything. And the reason for the problem
> is similar. It never occurred to me to store a heap variable
> in a Catalyst default value. ;-)
>
> But, now I know someone wants to do that, the solution is simple.
> If the internal pointer points to a heap variable, destroy that, too.
> And since I already spent an hour getting UNDEFINE to do just that
> a week ago, I decided to use that to get the job done.
>
> So, be sure you have the latest UNDEFINE, and you can download
> a new CatListValue object here:
>
> http://www.dfanning.com/programs/undefine.pro
> .../programs/catalyst/source/core/catlistvalue__define.pro
>
> Tested only lightly, as I am late for work, as usual. :-)

Whoops! Should have tested this more extensively for the
Law of Unintended Consequences. :-(

It was a good idea, in theory, but it had trickle down
effects in other parts of Catalyst. The most sensible course
seems to me to keep the underlying behavior the same,
but to allow different behavior by means of a keyword.
(Almost *always* the most sensible course, but I do not
always think clearly before the coffee kicks in.)

Thus, three Catalyst routines have changed to support a
DESTROY_ON_CLEANUP keyword to the CatListValue object.
If this keyword is set, the IDL variable stored in the
CatListValue storage location is destroyed with UNDEFINE
when the CatListValue object is destroyed.

The same keyword is available now for CatSetDefault, so
that you can destroy variables when default variables are
cleaned up. The following code will prevent memory leakage
when storing an object as a Catalyst default value.

pb = Obj_New('ProgressBar')
CatSetDefault, 'ProgressBar', pb, /DESTROY_ON_CLEANUP
CatDestroyDefaults

The following three routines have changed:

.../catalyst/source/utilities/catsetdefault.pro
.../catalyst/source/core/catlist__define.pro
.../catalyst/source/core/catlistvalue__define.pro

Documentation of this keyword is pretty extensive, but
please ask questions if you are not clear about it.

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.")
[Message index]
 
Read Message
Read Message
Previous Topic: Aishwarya Aravind's Mamiyar veedu (Chennai (Madras))
Next Topic: Re: "include" a file

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

Current Time: Fri Oct 10 12:24:37 PDT 2025

Total time taken to generate the page: 1.91626 seconds