Talk:Generics Defaults TComparer (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

I'm using Delphi XE Pro. I have a crash in custom sort case:

 procedure TForm3.btCustomSortClick(Sender: TObject);
 var
   Cmp : TIntStringComparer;
 begin
   { Use our custom comparer }
   Cmp := TIntStringComparer.Create();
   try
     SortMemos(Cmp);
   finally
     Cmp.free;     // <------ crash is here. 'Invalid pointer operation'
   end;
 end;


Thank you for your input! We're investigating this in RAD-10499.--Denisa Tibeica


The crash above is probably to be expected, as TIntStringComparer inherits ultimately from TInterfacedObject, which is reference counted, and hence disposed before getting to finally. Bottom line, so far as I can see, no need to free comparers that inherit from TComparer. Gwideman 16:13, 20 February 2012 (PST)