[fpc-pascal] Is it posible to implement more than one interface in a class defination?
Andrew Hall
andrew.hall at shaw.ca
Sun Nov 14 20:22:02 CET 2010
I suspect the reason is that the object still has a refCount of 1 when you free it and this code raises the exception:
procedure TInterfacedObject.BeforeDestruction;
begin
if frefcount<>0 then
HandleError(204);
end;
You should never free an interfaced object directly.
Regards Andrew.
On 14 Nov 10, at 09:27 , Sven Barth wrote:
> You're right of course...
>
> The following code flow works:
>
> begin
> t := TMyInterfacedObject.Create;
> i := t;
> t.Foo;
> i.Foo;
> end;
>
> But why doesn't the following?
>
> begin
> t := TMyInteracedObject.Create;
> try
> t._AddRef;
> i := t;
> t.Foo;
> i.Foo;
> i := Nil; // shouldn't this solve the problem as well? or is this a problem of temp inteface variables?
> finally
> t.Free;
> end;
> end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20101114/6a262009/attachment.html>
More information about the fpc-pascal
mailing list