Skip to content

Commit 7bbd6da

Browse files
committed
* Fixed mem leak reported in issue #1001
* Partial fix for issue #1013: Changing the Check State from InitNode may leave the tree in "updating" state.
1 parent 110b6d8 commit 7bbd6da

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Source/VirtualTrees.pas

+8-4
Original file line numberDiff line numberDiff line change
@@ -12178,7 +12178,8 @@ constructor TBaseVirtualTree.Create(AOwner: TComponent);
1217812178
//----------------------------------------------------------------------------------------------------------------------
1217912179

1218012180
destructor TBaseVirtualTree.Destroy;
12181-
12181+
var
12182+
WasValidating: Boolean;
1218212183
begin
1218312184
// Disconnect all remote MSAA connections
1218412185
if Assigned(FAccessibleItem) then begin
@@ -12190,7 +12191,10 @@ destructor TBaseVirtualTree.Destroy;
1219012191
fAccessible := nil;
1219112192
end;
1219212193

12194+
WasValidating := (tsValidating in FStates);
1219312195
InterruptValidation(True);
12196+
if WasValidating then
12197+
CheckSynchronize(); // Make sure to dequeue all synchronized calls from ChangeTreeStatesAsync(), fixes mem leak reported in issue #1001.
1219412198
Exclude(FOptions.FMiscOptions, toReadOnly);
1219512199
// Make sure there is no reference remaining to the releasing tree.
1219612200
TWorkerThread.ReleaseThreadReference();
@@ -25705,7 +25709,7 @@ procedure TBaseVirtualTree.ValidateCache();
2570525709

2570625710
begin
2570725711
// stop validation if it is currently validating this tree's cache.
25708-
InterruptValidation(False);
25712+
InterruptValidation();
2570925713

2571025714
FStartIndex := 0;
2571125715
if (tsValidationNeeded in FStates) and (FVisibleCount > CacheThreshold) then
@@ -32628,7 +32632,7 @@ procedure TBaseVirtualTree.UpdateHorizontalScrollBar(DoRepaint: Boolean);
3262832632
begin
3262932633
UpdateHorizontalRange;
3263032634

32631-
if (tsUpdating in FStates) or not HandleAllocated then
32635+
if (FUpdateCount > 0) or not HandleAllocated then
3263232636
Exit;
3263332637

3263432638
// Adjust effect scroll offset depending on bidi mode.
@@ -32735,7 +32739,7 @@ procedure TBaseVirtualTree.UpdateVerticalScrollBar(DoRepaint: Boolean);
3273532739
begin
3273632740
UpdateVerticalRange;
3273732741

32738-
if tsUpdating in FStates then
32742+
if (fUpdateCount > 0) then
3273932743
Exit;
3274032744
Assert(GetCurrentThreadId = MainThreadId, 'UI controls like ' + Classname + ' and its scrollbars should only be manipulated through the main thread.');
3274132745

0 commit comments

Comments
 (0)