TCollection TCollectionItem

I have written a class that is derived from the TCollection class
(TTelMacroList) and another derived from the TCollectionItem class
(TTelMacro) The classes are accessed as a property in another component
derived from TWinControl (TTelAction)

The TTelMacro class contains references to other components within the
application as follows below:

Every thing seems to work as it should and values are retained during
compilation and the re-opening of the project.

The problem I suspect I am having is a memory leak somewhere. It causes the
builder to report errors when exiting... or deconstructing the class,
however I am difficulty tracking where it occurs.

Can somebody suggest the correct deconstructor that I should use for the
TTelAction, TTelMacroList and TTelMacro classes. Should I have any on the
macro classes if they are properties of a component, does the component
handle the cleanup of it's properties?

I am using the FreeNotification method on the TTelAction Component when
setting the component values for the TTelMacro class. This calls the
TTelMacroList::FreeReference which calls the TTelMacro::FreeReference.

Please advise me if you require more of the code...

Thanks in advance, Cam

class TTelMacro : public TCollectionItem
{
friend class TTelMacroList;
private:
    TTelMacroList*  macrolist;
    EAction         action;
    String          eventtime;
    bool            terminate;

    TWinControl*    component1;
    TWinControl*    component2;
    TWinControl*    component3;
    TWinControl*    component4;

    String          string1;
    String          string2;
    String          string3;
    String          string4;

    void __fastcall SetCollection(TTelMacroList* list);
    TTelMacroList* __fastcall GetCollection(void);

    void __fastcall SetAction(EAction act);

    void __fastcall SetComponent1(TWinControl* cmp);
    void __fastcall SetComponent2(TWinControl* cmp);
    void __fastcall SetComponent3(TWinControl* cmp);
    void __fastcall SetComponent4(TWinControl* cmp);
    void __fastcall FreeReference(TComponent* remove);

protected:
    void __fastcall MSwapAction();
    void __fastcall MActionList();
    void __fastcall MSwapButton();
    void __fastcall MUpdateButton();
    void __fastcall MDisplayButton();
    void __fastcall MChangeLED();
    void __fastcall MPlacePosition();
    void __fastcall MSendExternalData();
    void __fastcall MMenuSet();
public:
    __fastcall TTelMacro(TCollection* Collection);
    __fastcall ~TTelMacro();
    void __fastcall Activate();
    void __fastcall Assign(TPersistent *Source);
    __property TTelMacroList* Collection = {read=GetCollection,
write=SetCollection, nodefault};
__published:
  // published class properties
    __property EAction Action = {read=action, write=SetAction, default =
NoAction};
    __property String EventTime = {read=eventtime, write=eventtime};
    __property bool TerminateThread = {read=terminate, write=terminate,
default = false};

    __property TWinControl* Component1 = {read=component1,
write=SetComponent1,default = NULL};
    __property TWinControl* Component2 = {read=component2,
write=SetComponent2,default = NULL};
    __property TWinControl* Component3 = {read=component3,
write=SetComponent3,default = NULL};
    __property TWinControl* Component4 = {read=component4,
write=SetComponent4,default = NULL};

    __property String String1 = {read=string1, write=string1};
    __property String String2 = {read=string2, write=string2};
    __property String String3 = {read=string3, write=string3};
    __property String String4 = {read=string4, write=string4};

Quote
};

class TTelMacroList : public TCollection
{
friend class TTelMacro;
private:
// private data members
    TComponent *FOwner;
protected:
// overriden protected member functions
    void __fastcall SetItem(int index, TTelMacro* macro);
    TTelMacro* __fastcall GetItem(int index);
    DYNAMIC TPersistent* __fastcall GetOwner(void);
public:
    __fastcall TTelMacroList(TComponent *Owner);
    __fastcall ~TTelMacroList();
    void __fastcall FreeReference(TComponent* remove);
// overriden public member functions
    virtual void __fastcall Assign(TPersistent* Source);
    TTelMacro* __fastcall Add();
// public member functions
    void __fastcall DeleteItem(int index);
    int __fastcall Move(int pos, int direction);
    int __fastcall Insert(int pos, TTelMacro* macro);

    void __fastcall DeleteItem(TTelMacro* macro);
    __property TTelMacro* Items[int Index] = {read=GetItem, write=SetItem};

Quote
};