ShellCtrls: Speed up population of TShellListView by adding BeginUpdate/EndUpdate calls.

git-svn-id: trunk@64553 -
This commit is contained in:
wp 2021-02-12 15:04:54 +00:00
parent ad98b8ef31
commit b729025142

View File

@ -862,6 +862,7 @@ begin
if (csDesigning in ComponentState) then Exit;
Files := TStringList.Create;
Items.BeginUpdate;
try
Files.OwnsObjects := True;
GetFilesInDir(ANodePath, AllFilesMask, FObjectTypes, Files, FFileSortType);
@ -886,6 +887,7 @@ begin
end;
finally
Files.Free;
Items.EndUpdate;
end;
end;
@ -899,6 +901,8 @@ var
begin
// avoids crashes in the IDE by not populating during design
if (csDesigning in ComponentState) then Exit;
Items.BeginUpdate;
try
Items.Clear;
r := GetLogicalDriveStrings(SizeOf(Drives), Drives);
if r = 0 then Exit;
@ -916,6 +920,9 @@ begin
NewNode.HasChildren := True;
Inc(pDrive, 4);
end;
finally
Items.EndUpdate;
end;
end;
{$else}
var
@ -1409,9 +1416,14 @@ begin
and not DirectoryExistsUtf8(ExpandFilenameUtf8(Value)) then
Raise EInvalidPath.CreateFmt(sShellCtrlsInvalidRoot,[Value]);
FRoot := Value;
BeginUpdate;
try
Clear;
Items.Clear;
PopulateWithRoot();
finally
EndUpdate;
end;
end;
end;
@ -1455,6 +1467,7 @@ begin
// Check inputs
if Trim(FRoot) = '' then Exit;
Items.BeginUpdate;
Files := TStringList.Create;
try
Files.OwnsObjects := True;
@ -1489,6 +1502,7 @@ begin
Sort;
finally
Files.Free;
Items.EndUpdate;
end;
end;