Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 2,098
    • Issues 2,098
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #40022
Closed
Open
Issue created Nov 28, 2022 by K H@d7_2_laz

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!

Assignee
Assign to
Time tracking