Skip to content

Commit 85e45e0

Browse files
committed
Revert "Issue #1146: Revert initial change. Do not set toAutoSort by default, but only if OnCompareNodes is assigned"
This reverts commit 6ed0528.
1 parent 6365165 commit 85e45e0

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

Source/VirtualTrees.BaseTree.pas

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,6 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor)
913913
function IsStored_Indent: Boolean;
914914
function IsStored_Margin: Boolean;
915915
function IsStored_TextMargin: Boolean;
916-
procedure SetOnCompareNodes(const Value: TVTCompareEvent);
917916
protected
918917
FFontChanged: Boolean; // flag for keeping informed about font changes in the off screen buffer // [IPK] - private to protected
919918
procedure AutoScale(); virtual;
@@ -1310,7 +1309,7 @@ TBaseVirtualTree = class abstract(TVTBaseAncestor)
13101309
property OnColumnWidthDblClickResize: TVTColumnWidthDblClickResizeEvent read FOnColumnWidthDblClickResize
13111310
write FOnColumnWidthDblClickResize;
13121311
property OnColumnWidthTracking: TVTColumnWidthTrackingEvent read FOnColumnWidthTracking write FOnColumnWidthTracking;
1313-
property OnCompareNodes: TVTCompareEvent read FOnCompareNodes write SetOnCompareNodes;
1312+
property OnCompareNodes: TVTCompareEvent read FOnCompareNodes write FOnCompareNodes;
13141313
property OnCreateDataObject: TVTCreateDataObjectEvent read FOnCreateDataObject write FOnCreateDataObject;
13151314
property OnCreateDragManager: TVTCreateDragManagerEvent read FOnCreateDragManager write FOnCreateDragManager;
13161315
property OnCreateEditor: TVTCreateEditorEvent read FOnCreateEditor write FOnCreateEditor;
@@ -5659,12 +5658,6 @@ procedure TBaseVirtualTree.SetOffsetY(const Value: TDimension);
56595658

56605659
//----------------------------------------------------------------------------------------------------------------------
56615660

5662-
procedure TBaseVirtualTree.SetOnCompareNodes(const Value: TVTCompareEvent);
5663-
begin
5664-
FOnCompareNodes := Value;
5665-
Self.TreeOptions.AutoOptions := TreeOptions.AutoOptions + [TVTAutoOption.toAutoSort]; // See issue #1146
5666-
end;
5667-
56685661
procedure TBaseVirtualTree.SetOnPrepareButtonImages(const Value: TVTPrepareButtonImagesEvent);
56695662
begin
56705663
FOnPrepareButtonImages := Value;
@@ -22533,6 +22526,8 @@ procedure TBaseVirtualTree.SortTree(Column: TColumnIndex; Direction: TSortDirect
2253322526
begin
2253422527
if RootNode.TotalCount <= 2 then
2253522528
Exit;//Nothing to do if there are one or zero nodes. RootNode.TotalCount is 1 if there are no nodes in the treee as the root node counts too here.
22529+
if not Assigned(OnCompareNodes) then
22530+
exit;// no sorting will take place without an event handler. Issue #1146
2253622531

2253722532
if not Assigned(FRoot.FirstChild) then
2253822533
Exit; // Sorting should not initialize the root nodes

Source/VirtualTrees.Types.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ TChunkHeader = record
774774
const
775775
DefaultPaintOptions = [toShowButtons, toShowDropmark, toShowTreeLines, toShowRoot, toThemeAware, toUseBlendedImages];
776776
DefaultAnimationOptions = [];
777-
DefaultAutoOptions = [toAutoDropExpand, toAutoTristateTracking, toAutoScrollOnExpand, toAutoDeleteMovedNodes, toAutoChangeScale, toAutoHideButtons];
777+
DefaultAutoOptions = [toAutoDropExpand, toAutoTristateTracking, toAutoScrollOnExpand, toAutoDeleteMovedNodes, toAutoChangeScale, toAutoSort, toAutoHideButtons];
778778
DefaultSelectionOptions = [toSelectNextNodeOnRemoval];
779779
DefaultMiscOptions = [toAcceptOLEDrop, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick];
780780

0 commit comments

Comments
 (0)