[fpc-pascal] Delegate Interface class does not seem to be referenced counted
Marcos Douglas
md at delfire.net
Wed Aug 10 14:57:28 CEST 2016
Hi,
See the "problem" bellow:
TMyClass = class(TInterfacedObject, IMyInterface)
private
FMyInterface: TDelegateClass; <<< HERE >>>
property MyInterface: TDelegateClass
read FMyInterface implements IMyInterface;
public
constructor Create(obj: TDelegateClass);
destructor Destroy; override;
end;
and...
procedure TDelegateTest.DoRun;
var Intf: IMyInterface;
Intf2: IMyInterface;
begin
Intf := TMyClass.Create(TDelegateClass.Create); <<< HERE >>>
Intf2 := TDelegateClass.Create;
You're treating the instance using class types instead of interface type.
You can:
1. Change FMyInterface: TDelegateClass to FMyInterface: IMyInterface;
or
2. Destroy FMyInterface on destructor.
Best regards,
Marcos Douglas
More information about the fpc-pascal
mailing list