View Issue Details

IDProjectCategoryView StatusLast Update
0035767LazarusIDEpublic2020-04-12 15:10
ReporterFTurtle Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
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 Revisionr62816
LazTarget-
Widgetset
Attached Files

Relationships

related to 0036787 resolvedJuha Manninen The filter of the code explorer should expand the results up to the terminal nodes 
related to 0036896 new Trunk IDE - Code Explorer filter does not work 

Activities

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
    FilterNode(ANode,TheFilter);
    ANode:=ANode.GetNextSibling;
  end;
...

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}
{$h+}
{$codepage utf8}
{$define debug_gettextfiletype}
{$R *.lfm}
{$if fpc_fullversion > 30200}
{$else}
{$endif}
{$if fpc_fullversion > 30200}
{$else}
{$endif}


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}"
  TheFilter="$if"
  (ANode.Parent<>nil)=False
  (CurrentPage=cepDirectives)=True
  ((ANode.Parent<>nil) or (CurrentPage=cepDirectives))=True
  (ANode.GetFirstChild=nil)=True
  not FilterFits=True
  Result=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

Juha Manninen

2020-03-29 23:56

developer   ~0121758

Fixed, please test.

> If FilterNode=True then inside FilterNode ANode gets freed (DeleteTVNode will do that).
@Bart, I also wonder how it worked at all. I guess it worked by accident.
Yes, when the Parent rule was changed it crashed. I fixed it everywhere so the node's sibling is fetches before freeing the node.
There were plenty more bugs to fix before the filter for directives started to work.

FTurtle

2020-03-30 21:38

reporter   ~0121782

Thank you.

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
2020-03-19 00:42 Juha Manninen Relationship added related to 0036787
2020-03-29 23:47 Juha Manninen Assigned To => Juha Manninen
2020-03-29 23:47 Juha Manninen Status confirmed => assigned
2020-03-29 23:56 Juha Manninen Status assigned => resolved
2020-03-29 23:56 Juha Manninen Resolution open => fixed
2020-03-29 23:56 Juha Manninen Fixed in Revision => r62816
2020-03-29 23:56 Juha Manninen Note Added: 0121758
2020-03-30 21:38 FTurtle Status resolved => closed
2020-03-30 21:38 FTurtle Note Added: 0121782
2020-04-12 15:10 Juha Manninen Relationship added related to 0036896