Cleaning up an inherited object... [message #84969] |
Thu, 20 June 2013 02:17  |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Dear OO-IDLers,
[You don't need to read this post if what is in
https://groups.google.com/forum/?fromgroups#!searchin/comp.l ang.idl-pvwave/cleanup$20inherited$20object/comp.lang.idl-pv wave/5zEpZQxJmDM/7-U023w14YEJ
is already obvious to you... I've just spend half an hour figuring out how to cleanup inherited objects and just found out that I needed the Self->IDLanROI::CleanUp command in my cleanup method... damm...
Lesson: inherited objects have to be cleaned up in the subclass objects]
I've made an object that is a subclass of an IDLanROI object. I define some extra properties to the IDLanROI. I call my object this way:
SmallSquareROI = OBJ_NEW('eaROIobj', EA_Type=Type, SquareSize = 5.0)
and after creating it I get the following result from help, /heap:
Heap Variables:
# Pointer: 2
# Object : 1
<ObjHeapVar1> refcount=1
STRUCT = -> EAROIOBJ Array[1]
<PtrHeapVar2> refcount=1
STRING = Array[7]
<PtrHeapVar3> refcount=1
DOUBLE = Array[3, 100]
When I then destroy the object, I am left with the following:
Heap Variables:
# Pointer: 1
# Object : 0
<PtrHeapVar3> refcount=0
DOUBLE = Array[3, 100]
So somewhere I there is a pointer that is not "cleanedup" and that is <PtrHeapVar3>. So I look for the creation of this pointer in my code and I find that <PtrHeapVar3> is created in this line in the Init method:
self->SetProperty, Data=self.SmallSquareCoord
where self.SmallSquareCoord is:
<Expression> DOUBLE = Array[2, 5]
So the Data in the IDLanROI is stored as a pointer. Not surprising. However two I notice that the number of points stored in IDLanROI is 100 and N_VERTS is set to 5 to disregard the other when actually using the data. Therefore I end up with an array such as [3,100].
However, it seems like I cannot clean up this "data" property of the IDLanROI inherited object... what am I doing wrong? I thought that when calling the cleanup method for the subclass object also the superclass object cleanup method is called.
Does anybody have a suggestion how to account for this?
Of course it is my first inherited object... so I'm at the beginning of a long learning curve :-)
Cheers,
Helder
|
|
|
Re: Cleaning up an inherited object... [message #84974 is a reply to message #84969] |
Thu, 20 June 2013 05:33  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Helder writes:
> I've just spend half an hour figuring out how to cleanup inherited objects and just found out that I needed the Self->IDLanROI::CleanUp command in my cleanup method... damm...
Helder, Helder, Helder. You really have to start paying attention to
some of the things I've been writing about for 20+ years. :-)
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.")
|
|
|