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

Reply via email to