Delphi2009 泛型容器遍历超界问题

今天用TDictionary,发现居然一个成员的集合遍历里有2次。。。。就是下面简单的遍历

var
  LPair : TPair<Integer,TForm>;
begin
  for LPair in FFormDictionary do
  begin
    TForm(LPair.Value).free;
  end;

导致FFF0006C的内存溢出!,网上搜索了一下,解决方法如下:

打开Generics.Collections单元,

#1. 1679 inherited;”改为: inherited Create;

#2. 修改三处(第1596行、第1631行、第1666行)“while FIndex < Length(FDictionary.FItems) do”为 while FIndex < Length(FDictionary.FItems) - 1 do

具体的分析可以借鉴:http://www.52delphi.com/list.asp?ID=760

附件:修正的Generics.Collections.dcu

posted @ 2010-05-17 13:15  Enli  阅读(840)  评论(0编辑  收藏  举报