Re: Where is the trick in objects [message #34628 is a reply to message #34623] |
Thu, 10 April 2003 01:30   |
Thomas Gutzler
Messages: 44 Registered: November 2002
|
Member |
|
|
David Fanning wrote:
> Thomas Gutzler (tgutzler@ee.uwa.edu.au) writes:
>
>
>> I think I ran into a little problem while trying to program my own
>> object. I can create it, work with it, and destroy it. But I can't get
>> rid of uncleared heap variables.
>> I tried a ::KILL method which uses 'heap_free, self' or ptr_free and
>> obj_delete on several self.variables and self.objects.
>> obj_destroy, myobject doesn't work, too.
>>
>> I'm kind of clueless.
>
>
> Oh, dear. Someone needs to write a book on this subject. :-(
Yeah, I'll do that later :)
>> My object generates a base widget and some dependent widgets (draw, ..),
>> views an image and a polyline and modifies this image. I think, closing
>> the base widget without a cleanup-function causes the leak, but PsConfig
>> doesn't have a cleanup, too :/
>
>
> I didn't see a CLEANUP method, but you certainly need one.
> I would name your KILL method CLEANUP. The CLEANUP method
> will be called automatically when the object is destroyed.
That one was pretty helpfull.
> The problem you are trying to solve with your ALL structure
> is that you are trying to do something in an event handler
> procedure that really wants to be done in an event handler
> *method*. This is the problem I alluded to earlier today:
> How do you combine widget functionality with object methodology?
>
> The easiest way to do this is store the object reference (self)
> in the UVALUE of the top-level base. Then make all your events
> go to an event handler procedure like this:
>
> PRO OBJECT_EVENT_DISPATCHER, event
> Widget_Control, event.top, Get_UValue=theObject
> theObject -> EVENT_HANDLER, event
> END
And this was even more helpfull!
IDL> a = OBJ_new('GUI_CC', array) & a->gui
(... work with the gui ...)
IDL> obj_destroy, a
IDL> help, /heap
Heap Variables:
# Pointer: 0
# Object : 0
Thanks a lot - again - David.
lucky,
Tom
|
|
|