害我查了半天的错误!av错误,小心Component对象使用Application当Owner

var
  ConnectionService := TConnService;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
  ConnectionService := TConnService.Create(Application);
end;

destructor TfrmMain.Destroy;
begin
  ConnectionService.Free//执行这里时出错,原因使用Application当Owner
//,在这之前Application自动把ConnectionService释放掉了(把Owner为Application的都释放掉了)
  inherited;
end;

这样会出错,frmMain为Application的主窗体
posted @ 2007-01-16 00:11  D10.天地弦  阅读(502)  评论(4编辑  收藏  举报