On Thu, 15 May 2008 14:43:20 -0400
Lee Jenkins <[EMAIL PROTECTED]> wrote:

> 
> I've never tried this type of thing before, but I have need to have
> an object free self.
> 
> After freeing any resource used by the object in it's Destructor, I
> call inherited destroy and it looks like the inherited destroy
> methods works, but right afterward, get a sig exception in
> LCLProc.unit:
> 
> function TMethodList.Count: integer;
> begin
>    if Self<>nil then
>      Result:=FCount <== here
>    else
>      Result:=0;
> end;
> 
> Is it even possible to have an object free itself?

Yes.
In fact, it does not matter who frees it. Just make sure, all refences
to the object are set to nil.


> BTW, I'm trying my hand at creaing an MVC and I need the controller
> to be able to free itself because it is the object that 1) Creates
> the View (form) and 2) the Model (object) and mediates between them.
> 
> When the form is closed, the controller is notified and need to 1)
> free the form 2) free the model/object and 3) free itself.
> 
> Otherwise, I guess I must create some kind of manager object/list to
> free the controller from the outside.  Note: If I free the controller
> object from outside (like putting it in an objectlist and calling
> ObjectList.clear) there is no exception.
> 
> Just calling free from the object itself poses the problem.

Create a backtrace. Find out, where something accesses the control
after it has been freed.

Mattias
_______________________________________________
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to