View Issue Details

IDProjectCategoryView StatusLast Update
0033064LazarusLCLpublic2020-03-31 14:30
ReporterVojtech Cihak Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSLinux 
Product Version1.9 (SVN) 
Summary0033064: Wrong alphabetical sorting in TreeView
DescriptionDefault sorting (TTreeNode.AlphaSort) is wrong.
Steps To ReproduceRun demo. Click FillNode. Nodes is filled 1, 2, 3 ...
Now click AlphaSort. Now order is 1, 10, 11, 2, 3 ...

Note that there is double space in front of 1,, 2, 3 and single space in front of 10 and 11.
Additional InformationLazarus 1.9.0 r57141M FPC 3.0.4 x86_64-linux-qt
TagsNo tags attached.
Fixed in Revision62828
LazTarget-
WidgetsetGTK 2, QT, QT5
Attached Files

Activities

Vojtech Cihak

2018-01-22 15:54

reporter  

treeviewAlpha.zip (2,285 bytes)

Pascal Riekenberg

2018-01-22 15:58

developer   ~0106011

Maybe the problem starts here:

Index: treeview.inc
===================================================================
--- treeview.inc (revision 57141)
+++ treeview.inc (working copy)
@@ -290,8 +290,10 @@
   if (Node1.TreeView<>nil) and Assigned(Node1.TreeView.OnCompare) then begin
     Result:=0;
     Node1.TreeView.OnCompare(Node1.TreeView,Node1, Node2, Result);
- end else
+ end else begin
     Result := AnsiCompareStr(Node1.Text,Node2.Text);
+ DebugLn(' *** TTreeNode.DefaultTreeViewSort %s, %s, %d', [Node1.Text, Node2.Text, Result]);
+ end;
 end;
 
 constructor TTreeNode.Create(AnOwner: TTreeNodes);

Serge Anvarov

2018-01-22 16:20

reporter   ~0106014

Lazarus 1.8.0. Windows. The code in treeview.inc is the same, but sorts as expected: 'Item 1', 'Item 2', ..., 'Item 10'

Pascal Riekenberg

2018-01-22 16:56

developer   ~0106016

It seems to be a Linux issue. Works on Laz trunk , windows 10.

Zeljan Rikalo

2020-03-31 13:03

developer   ~0121796

Please test and close if ok.

Pascal Riekenberg

2020-03-31 14:30

developer   ~0121799

Could this be the solution? I don't think so, it's just a workaround.
The root cause is that AnsiCompareStr behaves different on Unix, IMHO!

Issue History

Date Modified Username Field Change
2018-01-22 15:54 Vojtech Cihak New Issue
2018-01-22 15:54 Vojtech Cihak File Added: treeviewAlpha.zip
2018-01-22 15:58 Pascal Riekenberg Note Added: 0106011
2018-01-22 16:20 Serge Anvarov Note Added: 0106014
2018-01-22 16:56 Pascal Riekenberg Note Added: 0106016
2020-03-31 12:55 Zeljan Rikalo LazTarget => -
2020-03-31 12:55 Zeljan Rikalo Widgetset QT => GTK 2, QT, QT5
2020-03-31 13:03 Zeljan Rikalo Assigned To => Zeljan Rikalo
2020-03-31 13:03 Zeljan Rikalo Status new => resolved
2020-03-31 13:03 Zeljan Rikalo Resolution open => fixed
2020-03-31 13:03 Zeljan Rikalo Fixed in Revision => 62828
2020-03-31 13:03 Zeljan Rikalo Widgetset GTK 2, QT, QT5 => GTK 2, QT, QT5
2020-03-31 13:03 Zeljan Rikalo Note Added: 0121796
2020-03-31 14:30 Pascal Riekenberg Note Added: 0121799