View Issue Details

IDProjectCategoryView StatusLast Update
0035767LazarusIDEpublic2020-02-09 17:13
ReporterFTurtleAssigned To 
Status confirmedResolutionopen 
Product Version2.1 (SVN)Product Build61478 
Target VersionFixed in Version 
Summary0035767: Code Explorer: Filter for directives does not work.
DescriptionFilter for directives in Code Explorer does not work.
I don't know did it ever work but in 1.6.0 it not works.
Steps To Reproduce1. Open any source file which contain directives.
2. Go to Code Explorer.
3. Switch to "Directives" tab.
4. Try input something in filter. It not works.
TagsNo tags attached.
Fixed in Revision
Attached Files


Bart Broersma

2020-02-09 00:14

developer   ~0120959

function TCodeExplorerView.FilterNode(ANode: TTreeNode;
  const TheFilter: string): boolean;
  Result:=(ANode.Parent<>nil) and (ANode.GetFirstChild=nil)
          and (not FilterFits(ANode.Text,TheFilter));

Always evaluates to False regardles wether FilterFits, because ANode.Parent = nil and ANode.GetFirstChild = nil

Bart Broersma

2020-02-09 16:42

developer   ~0120971

How can this work?

  while ANode<>nil do begin

If FilterNode=True then inside FilterNode ANode gets freed (DeleteTVNode will do that).

Bart Broersma

2020-02-09 16:57

developer   ~0120973

Last edited: 2020-02-09 17:13

View 5 revisions

In FilterNode if you change the condition
  (ANode.Parent<>nil) into
  ((ANode.Parent<>nil) or (CurrentPage=cepDirectives))
(because on that page the nodes have no parents)
then at least the first node gets removed (if it does not fit the filter), but then the recursion stops because inside ApplyDirectivesFilter ANode.GetNextSibling=nil. (Mind you ANode got freed in this case before the call to ANode.GetNextSibling).

Here's what happens if the filter text is "$if" and the list of directives (as shown in CodeExplorer) is:
{$mode objfpc}
{$codepage utf8}
{$define debug_gettextfiletype}
{$R *.lfm}
{$if fpc_fullversion > 30200}
{$if fpc_fullversion > 30200}

TCodeExplorerView.ApplyDirectivesFilter: GetFirstNode.Text="{$mode objfpc}", TheFilter="$if"
TCodeExplorerView.ApplyDirectivesFilter: ANode.Text="{$mode objfpc}", TheFilter="$if"
TCodeExplorerView.FilterNode: Has ChildNode=False //<== so, no recursion wil take place inside FilterNode
TCodeExplorerView.FilterNode "{$mode objfpc}"
  ((ANode.Parent<>nil) or (CurrentPage=cepDirectives))=True
  not FilterFits=True
TCodeExplorerView.DeleteTVNode: TVNode.Text={$mode objfpc} //<== Frees ANode
TCodeExplorerView.ApplyDirectivesFilter: After FilterNode: (OldNode=ANode)=True //<== I inserted OldNode:=ANode before the call to FilterNode
TCodeExplorerView.ApplyDirectivesFilter: After FilterNode: ANode.Text="" //<== ??
TCodeExplorerView.ApplyDirectivesFilter: (ANode.GetNextSibling<>nil)=False //<== while loop ends

Issue History

Date Modified Username Field Change
2019-06-25 21:29 FTurtle New Issue
2020-02-09 00:14 Bart Broersma Note Added: 0120959
2020-02-09 16:38 Bart Broersma Status new => confirmed
2020-02-09 16:38 Bart Broersma LazTarget => -
2020-02-09 16:42 Bart Broersma Note Added: 0120971
2020-02-09 16:57 Bart Broersma Note Added: 0120973
2020-02-09 17:02 Bart Broersma Note Edited: 0120973 View Revisions
2020-02-09 17:02 Bart Broersma Note Edited: 0120973 View Revisions
2020-02-09 17:12 Bart Broersma Note Edited: 0120973 View Revisions
2020-02-09 17:13 Bart Broersma Note Edited: 0120973 View Revisions