Bug in TCustomGrid.Sort
Original Reporter info from Mantis: corpsman @corpsman
-
Reporter name: Uwe Schächterle
Original Reporter info from Mantis: corpsman @corpsman
- Reporter name: Uwe Schächterle
Description:
TCustomGrid.Sort does not use SortOrder if OnCompareCells is assigned.
Steps to reproduce:
Start the attached program.
Click on the header of the columns (multiple times) the Columns will not be sorted
click on the "compare = nil" button, than the columns can be sorted.
Possible Fix could be :
within procedure TCustomGrid.Sort(ColSorting: Boolean; index, IndxFrom, IndxTo: Integer); ( grids.pas Line 2912)
if ColSorting then begin
if SortOrder = soAscending then begin // new
while DoCompareCells(index, P, index, I)>0 do I:=I+1;
while DoCompareCells(index, P, index, J)<0 do J:=J-1;
end else begin// new
while DoCompareCells(index, P, index, I)<0 do I:=I+1;// new
while DoCompareCells(index, P, index, J)>0 do J:=J-1;// new
end;// new
end else begin
if SortOrder = soAscending then begin // new
while DoCompareCells(P, index, I, index)>0 do I:=I+1;
while DoCompareCells(P, index, J, index)<0 do J:=J-1;
end else begin// new
while DoCompareCells(P, index, I, index)<0 do I:=I+1;// new
while DoCompareCells(P, index, J, index)>0 do J:=J-1;// new
end;// new end;
Or in
function TCustomGrid.DoCompareCells(Acol, ARow, Bcol, BRow: Integer): Integer;
begin
result := 0;
if Assigned(OnCompareCells) then
OnCompareCells(Self, ACol, ARow, BCol, BRow, Result);
if SortOrder <> soAscending then begin // new
result := -result;// new
end;// new
end;
Additional information:
Bug can be reproduced under Linux and Windows, in my oppinion it is not depend from the platform
Mantis conversion info:
- Mantis ID: 25772
- OS: Kubuntu
- OS Build: 13.10
- Build: 44121
- Platform: Linux
- Version: 1.3 (SVN)
- Monitored by: » @corpsman (Uwe Schächterle)