ShellTreeView Node Expand: second expand repopulates the node. And it is slower than the first one.
- Lazarus/FPC Version: <Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64__>
- Operating System: Windows x64
- CPU / Bitness: 64
What happens
When opening a collapsed node the second time, it will be populated again, and it takes twice of the time.
And: a selection of a sub-node previously being done will go lost
What did you expect
I expect
- when re-expanding the node, this is done instantly without clearing/repopulating the node No more node population is done again redundantly. And certainly not it should take twice the time.
I'd expect aht an already populated node can be re-expanded instantly.
For which reasons not do this code change? Wherefor a repopulation should be good for?
Steps to reproduce
Steps to reproduce
- Drop a ShellTreeView on a form
- Run the application and navigate to the folder (drivename:)\Windows\WinSxS
- Expand the node (fast!)
- Collapse the node
- Expand the node again. This takes at least twice as long. Slow!
Do the change described below (ShellCtrls.pas) and run the node's expand - collapse - expand again. Notice the time difference.
function TCustomShellTreeView.CanExpand(Node: TTreeNode): Boolean;
var
OldAutoExpand: Boolean;
begin
Result:=inherited CanExpand(Node);
if not Result then exit;
OldAutoExpand:=AutoExpand;
AutoExpand:=False;
BeginUpdate;
try
Result := True;
if Node.Count = 0 then begin // --- Added. Do it only if node is not yet populated
//Node.DeleteChildren; // --- Not needed regarding the condition
Result := PopulateTreeNodeWithFiles(Node, GetPathFromNode(Node));
end
else Result := True; // --- Added
AutoExpand:=OldAutoExpand;
finally
EndUpdate;
end;
end;
Side-effects of this change i couldn't detect so far. Might there be any ??
Supplementary note: i'd expect that when selecting a subnode "Sub1" beyond parent node "Parent1", that when i collapse Parent1 by click on the expand sign, and re-expand it again, the previous selection marker on Sub1 is preserved. Using the change, it stays preserved. By the current behaviour (= sub nodes cleanup) it goes lost. Not ok. Please keep my selection!