Generic TList<> in Delphi 2009 crash on IndexOf

后端 未结 2 649
余生分开走
余生分开走 2021-01-14 09:09

I\'ve seen many mentions of bugs in Delphi 2009 generics, but never expected something so basic to fail in Update 3, no less. Calling IndexOf on a generic TList or TObjectLi

相关标签:
2条回答
  • 2021-01-14 09:27

    Have a look at this question. Why is TList.Remove() producing an EAccessViolation error?

    In particular, try creating your TList like this

    TList<TTest>.Create(TComparer<TTest>.Default);
    
    0 讨论(0)
  • 2021-01-14 09:31

    This is a bug in the default constructor of TObjectList<T>, and I thought it was fixed in update 3. If you're still seeing it, use a different constructor or just update to D2010 or XE, where it's definitely fixed. (And you'll really want to get off of D2009 if you want to work with generics anyway.)

    0 讨论(0)
提交回复
热议问题