Marcos,
Thanks for the suggestions, but I had already tried the first variation:
TMyClass = class(TInterfacedObject, IMyInterface)
private
FMyInterface: IMyInterface; // class type
property MyInterface: IMyInterface
read FMyInterface implements IMyInterface;
public
constructor Create(obj: IMyInterface);
destructor Destroy; override;
end;
and that did not work.
Destroying FMyInterface in the destructor does not make a difference -
mainly because the TMyClass destructor is not being called anyway.
On 10/08/16 13:57, Marcos Douglas wrote:
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
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal