Title: Message
My understanding is:
 
1. If a component has an owner then the owner will try to free it during its destroy method leading to an access violation if it is freed elsewhere.  So if you are explicitly freeing it create it with Create(Nil).  N.B. for newcomers - this is totally different to specifying the Parent.
 
2. There is no reason why the method assigned to OnExit can't be a static method.
 
Stephen
-----Original Message-----
From: Paul Mckenzie [mailto:[EMAIL PROTECTED]
Sent: Friday, 19 March 2004 9:06 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Self Freeing

I like having an Owner - (But could if necessary have no Owner).
I want the Component initiate the free in a non-static method (eg OnExit, OnClick)
No longer referring to the variable - that is not a problem.
 
This is all just in the main (only) thread.
 
Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.
 
----- Original Message -----
Sent: Friday, March 19, 2004 8:46 AM
Subject: RE: [DUG] Self Freeing

AFAIK there is no problem executing Self.Free on the following conditions:
1. The object does not have an owner
2. The Self.Free statement is in a static method
3. The object is not later refered to from the generating program - either the object is not assigned to a variable or the variable is never accessed after the method call that results in the Free.
 
The real question is why you would want to do this outside a thread?
 
Stephen
-----Original Message-----
From: Stacey Verner [mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 March 2004 4:46 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] Self Freeing

In the case of a form override OnClose and set Action to caFree;.
 
procedure TMyForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;
 
Stacey
-----Original Message-----
From: Paul Mckenzie [mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 March 2004 16:23
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Self Freeing

But I want to self Free - ie immediately after executing its event it frees itself (eg OnClick).
 
Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.
 
----- Original Message -----
Sent: Thursday, March 18, 2004 4:07 PM
Subject: RE: [DUG] Self Freeing

Explicitly free it when you are done with it (maby add it to a list?) or set its owner to something valid so when the owner component is freed the dynamically created component will also be freed.
 
Stacey
-----Original Message-----
From: Paul Mckenzie [mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 March 2004 15:55
To: Delphi List - Delphi
Subject: [DUG] Self Freeing

What is the best way for a dynamically created component to free itself ?
 
 
Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.
 


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This communication contains information that is confidential and the copyright of ensynergy Limited or a third party.

If you are not the intended recipient of this communication please delete and destroy all copies and telephone ensynergy Limited on +64 9 3551591 immediately. If you are the intended recipient of this communication you should not copy, disclose or distribute this communication without the authority of ensynergy Limited.

Any views expressed in this communication are those of the individual sender, except where the sender specifically states them to be the views of ensynergy Limited.

Except as required by law, ensynergy Limited does not represent, warrant and/or guarantee that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This communication contains information that is confidential and the copyright of ensynergy Limited or a third party.

If you are not the intended recipient of this communication please delete and destroy all copies and telephone ensynergy Limited on +64 9 3551591 immediately. If you are the intended recipient of this communication you should not copy, disclose or distribute this communication without the authority of ensynergy Limited.

Any views expressed in this communication are those of the individual sender, except where the sender specifically states them to be the views of ensynergy Limited.

Except as required by law, ensynergy Limited does not represent, warrant and/or guarantee that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to