F
fwd
Unregistered / Unconfirmed
GUEST, unregistred user!
接口释放时不执行实例的destory,郁闷哪.... ?// -----------接口 ITest = interface ['{D302B875-A066-4598-8AD4-51FC4F722E79}'] function GetValue(var Value:string):boolean; end;//---实现接口的对象 TmyTest=class(TInterfacedObject,ITest) private Form:TFormObject; public constructor create; destructor destory; function GetValue(var Value:string):boolean; end;//------------------------------ 实现TMyTestconstructor TmyTest.create;begin Form:=TFormObject.Create(Nil); //为窗体Form, 有Edit1 , Button1 click 后 modalresult:=mrOk; end;destructor TmyTest.destory; // 此destory 不执行, 为何呀?begin ShowMessage('Freeing!'); Form.Free;end;function TmyTest.GetValue(var Value:string):boolean;begin result:=(Form.ShowModal=mrok); if result then value:=Form.Edit1.Text;end;// ------------------ 调用语句------procedure TForm1.Button1Click(Sender: TObject);var MyTest:ITest; s:string;begin MyTest:=TmyTest.create; //TMyTest 为窗口对象 IF MyTest.GetValue(s) then //接口过程GetValue ListBox1.Items.Insert(0,s); MyTest:=NIl; //接口被只为nil的时候 会自动释放对象 对吧? end;运行很正常,可就是不执行TmyTest.destory,是不是有内存泄漏, 不知错在哪了, 请帮我....