@@ -3130,6 +3130,7 @@ TBaseVirtualTree = class(TCustomControl)
3130
3130
function IsEditing: Boolean;
3131
3131
function IsMouseSelecting: Boolean;
3132
3132
function IsEmpty: Boolean; inline;
3133
+ function IsUpdating(): Boolean;
3133
3134
function IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer; Filter: TVirtualNodeStates = [];
3134
3135
DoInit: Boolean = False; ChildNodesOnly: Boolean = False): PVirtualNode;
3135
3136
procedure LoadFromFile(const FileName: TFileName); virtual;
@@ -8431,7 +8432,7 @@ procedure TVirtualTreeColumns.Update(Item: TCollectionItem);
8431
8432
Treeview.Invalidate;
8432
8433
end;
8433
8434
8434
- if not (tsUpdating in Treeview.FStates ) then
8435
+ if not (Treeview.IsUpdating ) then
8435
8436
// This is mainly to let the designer know when a change occurs at design time which
8436
8437
// doesn't involve the object inspector (like column resizing with the mouse).
8437
8438
// This does NOT include design time code as the communication is done via an interface.
@@ -19727,7 +19728,7 @@ procedure TBaseVirtualTree.DoColumnResize(Column: TColumnIndex);
19727
19728
if [hsColumnWidthTracking, hsResizing] * FHeader.States = [hsColumnWidthTracking] then
19728
19729
UpdateWindow(Handle);
19729
19730
19730
- if not (tsUpdating in FStates ) then
19731
+ if not (IsUpdating ) then
19731
19732
UpdateDesigner; // design time only
19732
19733
19733
19734
if Assigned(FOnColumnResize) and not (hsResizing in FHeader.States) then
@@ -23280,7 +23281,7 @@ procedure TBaseVirtualTree.InternalClearSelection();
23280
23281
// It is possible that there are invalid node references in the selection array
23281
23282
// if the tree update is locked and changes in the structure were made.
23282
23283
// Handle this potentially dangerous situation by packing the selection array explicitely.
23283
- if FUpdateCount > 0 then
23284
+ if IsUpdating then
23284
23285
begin
23285
23286
Count := PackArray(FSelection, FSelectionCount);
23286
23287
if Count > -1 then
@@ -30019,6 +30020,12 @@ function TBaseVirtualTree.IsMouseSelecting: Boolean;
30019
30020
Result := (tsDrawSelPending in FStates) or (tsDrawSelecting in FStates);
30020
30021
end;
30021
30022
30023
+ function TBaseVirtualTree.IsUpdating: Boolean;
30024
+ // The tree does currently not update its window because a BeginUpdate has not yet ended.
30025
+ begin
30026
+ Exit(UpdateCount > 0);
30027
+ end;
30028
+
30022
30029
//----------------------------------------------------------------------------------------------------------------------
30023
30030
30024
30031
function TBaseVirtualTree.IterateSubtree(Node: PVirtualNode; Callback: TVTGetNodeProc; Data: Pointer;
@@ -32636,7 +32643,7 @@ procedure TBaseVirtualTree.UpdateHorizontalScrollBar(DoRepaint: Boolean);
32636
32643
begin
32637
32644
UpdateHorizontalRange;
32638
32645
32639
- if (FUpdateCount > 0) or not HandleAllocated then
32646
+ if IsUpdating or not HandleAllocated then
32640
32647
Exit;
32641
32648
32642
32649
// Adjust effect scroll offset depending on bidi mode.
@@ -32743,7 +32750,7 @@ procedure TBaseVirtualTree.UpdateVerticalScrollBar(DoRepaint: Boolean);
32743
32750
begin
32744
32751
UpdateVerticalRange;
32745
32752
32746
- if (fUpdateCount > 0 ) then
32753
+ if (IsUpdating ) then
32747
32754
Exit;
32748
32755
Assert(GetCurrentThreadId = MainThreadId, 'UI controls like ' + Classname + ' and its scrollbars should only be manipulated through the main thread.');
32749
32756
0 commit comments