tms Grid sorting : Memoryleak

When using the Sorting option of tmsFMXGrid i get memoryleaks(for everytime a sort  is applied)

test case:

  1. Add a tmsfmxgrid and a clientdataset
  2. add 2 new fields to the clientdataset (a string and a integer)
  3. enable sorting in the grid options (gsmindexed)
  4. run and click on the columns
  5. (add the following to the project code)

  {$IFDEF DEBUG}
    ReportMemoryLeaksOnShutdown := True;
  {$ENDIF}

in my actual program i use the following code:

 TMSFMXGrid1.SortIndexes.Clear;
  if CHmanmodontop.IsChecked then
    TMSFMXGrid1.SortIndexes.AddIndex(6, sdAscending);
  case CBsort.ItemIndex of
    0: TMSFMXGrid1.SortIndexes.AddIndex(5, sdAscending);
    1: TMSFMXGrid1.SortIndexes.AddIndex(1, sdAscending);
    2: TMSFMXGrid1.SortIndexes.AddIndex(3, sdDescending);
    3: TMSFMXGrid1.SortIndexes.AddIndex(3, sdAscending);
  end;
  if TMSFMXGrid1.SortIndexes.Count>0 then
    TMSFMXGrid1.SortIndexed;

this also gives memoryleaks:

TRowinfo, TDatalist, unicodestring x6, Unknown


And another error is that when sorting mutiple columns, the row in the grid does not select the right row in the clientdataset. (using livebindings).

greetings






Hi, 


Sorting needs to be applied on the dataset. Internally sorting is applied to the grid and not automatically on the dataset.
You can implement the OnCanSort event and set Allow to false, and based on the sort setting perform a manual sort on the dataset directly. The dataset will automatically refresh the grid in a sorted state.

We are able to reproduce the memory leak and are still investigating the cause for this issue.

Kind Regards,
Pieter

When sorting the dataset, only the selected field in the grid is updated, even showing the selected row double if the order has changed.

can you wrap the sort with a beginupdate / endupdate ?


Kind Regards, 
Scheldeman Pieter

the problem still exists. you can try it in an new project.

add a grid and a clientdataset
add 2 fields to the clientdataset (string and integer)
add 3 indexes to the clientdataset (field1, field2, field2 descending
add a button and a combobox with 3 items
add the following code

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  ClientDataSet1.CreateDataSet;
    ClientDataSet1.Open;
  for i := 0 to 10 do
    ClientDataSet1.AppendRecord([inttostr(10-i)+'test',i]);
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  TMSFMXGrid1.BeginUpdate;
  case ComboBox1.ItemIndex of
    0:clientdataset1.IndexName:='index1';
    1:clientdataset1.IndexName:='index2';
    2:clientdataset1.IndexName:='index3';
  end;
    TMSFMXGrid1.endUpdate;
end;



Dear Mr. Vercruysse, thank you for the sample, 

we will investigate this here as soon as possible

Kind Regards, 
Pieter

thank you for the quick support

Dear Mr. Vercruysse,


we have fixed the memory leak here, the next version will address this.

Kind Regards, 
Pieter