fixed find in files mem leaks from Vincent

git-svn-id: trunk@4817 -
This commit is contained in:
mattias 2003-11-20 22:07:50 +00:00
parent ab8dea0921
commit 558dbcc490
4 changed files with 120 additions and 21 deletions

View File

@ -3,6 +3,7 @@ object SearchResultsView: TSearchResultsView
CLIENTHEIGHT = 225
CLIENTWIDTH = 799
ONCREATE = Form1Create
ONDESTROY = SearchResultsViewDestroy
HORZSCROLLBAR.PAGE = 800
VERTSCROLLBAR.PAGE = 226
LEFT = 280

View File

@ -3,13 +3,13 @@
LazarusResources.Add('TSearchResultsView','FORMDATA',[
'TPF0'#18'TSearchResultsView'#17'SearchResultsView'#7'CAPTION'#6#17'SearchRes'
+'ultsView'#12'CLIENTHEIGHT'#3#225#0#11'CLIENTWIDTH'#3#31#3#8'ONCREATE'#7#11
+'Form1Create'#18'HORZSCROLLBAR.PAGE'#3' '#3#18'VERTSCROLLBAR.PAGE'#3#226#0#4
+'LEFT'#3#24#1#6'HEIGHT'#3#225#0#3'TOP'#3#133#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK'
+#15'ResultsNoteBook'#5'ALIGN'#7#8'albottom'#7'ANCHORS'#11#5'aktop'#6'akleft'
+#0#17'ONCLOSETABCLICKED'#7#30'ResultsNoteBookClosetabclicked'#7'OPTIONS'#11
+#19'nboshowclosebuttons'#12'nbomultiline'#0#6'HEIGHT'#3#185#0#3'TOP'#2'('#5
+'WIDTH'#3#31#3#0#0#7'TBUTTON'#14'btnSearchAgain'#7'ANCHORS'#11#5'aktop'#6'ak'
+'left'#0#7'CAPTION'#6#12'Search Again'#7'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLIC'
+'K'#7#19'btnSearchAgainClick'#4'LEFT'#2#8#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH'
+#2's'#0#0#0
+'Form1Create'#9'ONDESTROY'#7#24'SearchResultsViewDestroy'#18'HORZSCROLLBAR.P'
+'AGE'#3' '#3#18'VERTSCROLLBAR.PAGE'#3#226#0#4'LEFT'#3#24#1#6'HEIGHT'#3#225#0
+#3'TOP'#3#133#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK'#15'ResultsNoteBook'#5'ALIGN'#7
+#8'albottom'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#17'ONCLOSETABCLICKED'#7#30'R'
+'esultsNoteBookClosetabclicked'#7'OPTIONS'#11#19'nboshowclosebuttons'#12'nbo'
+'multiline'#0#6'HEIGHT'#3#185#0#3'TOP'#2'('#5'WIDTH'#3#31#3#0#0#7'TBUTTON'#14
+'btnSearchAgain'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#7'CAPTION'#6#12'Search A'
+'gain'#7'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLICK'#7#19'btnSearchAgainClick'#4'L'
+'EFT'#2#8#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH'#2's'#0#0#0
]);

View File

@ -149,8 +149,8 @@ begin
fUpdating:= false;
end;//EndUpdate
{Brings The results tab named APageName to front if APageName does not exist
does nothing}
{Brings the results tab named APageName to front.
If APageName does not exist, does nothing}
procedure TSearchResultsView.BringResultsToFront(APageName: string);
begin
if PageExists(APageName) then
@ -213,8 +213,6 @@ var
SearchObj: TLazSearch;
begin
Result:= nil;
SearchObj:= TLazSearch.Create;
SearchObj.SearchString:= SearchText;
if Assigned(ResultsNoteBook) then
begin
With ResultsNoteBook do
@ -228,6 +226,8 @@ begin
else
begin
NewPage:= Pages.Add(ResultsName + SPACE);
SearchObj:= TLazSearch.Create;
SearchObj.SearchString:= SearchText;
fSearchObjectList.AddObject(ResultsName + SPACE, SearchObj);
if NewPage > -1 then
begin
@ -389,15 +389,15 @@ begin
if i > -1 then
begin
ThePage:= ResultsNoteBook.Page[i];
end;//if
if Assigned(ThePage) then
begin
TheListBox:= GetListBox(ThePage.PageIndex);
if Assigned(TheListBox) then
if Assigned(ThePage) then
begin
i:= TheListBox.ItemIndex;
if i > -1 then
result:= TheListBox.Items[i];
TheListBox:= GetListBox(ThePage.PageIndex);
if Assigned(TheListBox) then
begin
i:= TheListBox.ItemIndex;
if i > -1 then
result:= TheListBox.Items[i];
end;//if
end;//if
end;//if
end;//GetSelectedText

View File

@ -274,6 +274,30 @@ type
PPkgDependency = ^TPkgDependency;
{ TPkgPair }
TPkgPair = class
public
Package1: TLazPackage;
Package2: TLazPackage;
constructor Create(Pkg1, Pkg2: TLazPackage);
function ComparePair(Pkg1, Pkg2: TLazPackage): integer;
function Compare(PkgPair: TPkgPair): integer;
end;
{ TPkgPairTree }
TPkgPairTree = class(TAVLTree)
public
constructor Create;
destructor Destroy; override;
function FindPair(Pkg1, Pkg2: TLazPackage; IgnoreOrder: boolean): TPkgPair;
function AddPair(Pkg1, Pkg2: TLazPackage): TPkgPair;
function AddPairIfNotExists(Pkg1, Pkg2: TLazPackage): TPkgPair;
end;
{ TPkgCompilerOptions }
TPkgCompilerOptions = class(TBaseCompilerOptions)
@ -3220,6 +3244,80 @@ begin
Result:='$(TestDir)/publishedpackage/';
end;
{ TPkgPairTree }
function ComparePkgPairs(Pair1, Pair2: TPkgPair): integer;
begin
Result:=Pair1.Compare(Pair2);
end;
constructor TPkgPairTree.Create;
begin
inherited Create(@ComparePkgPairs);
end;
destructor TPkgPairTree.Destroy;
begin
FreeAndClear;
inherited Destroy;
end;
function TPkgPairTree.FindPair(Pkg1, Pkg2: TLazPackage; IgnoreOrder: boolean
): TPkgPair;
var
Comp: integer;
ANode: TAVLTreeNode;
begin
ANode:=Root;
while (ANode<>nil) do begin
Result:=TPkgPair(ANode.Data);
Comp:=Result.ComparePair(Pkg1,Pkg2);
if Comp=0 then exit;
if Comp<0 then begin
ANode:=ANode.Left
end else begin
ANode:=ANode.Right
end;
end;
if IgnoreOrder then
Result:=FindPair(Pkg2,Pkg1,false)
else
Result:=nil;
end;
function TPkgPairTree.AddPair(Pkg1, Pkg2: TLazPackage): TPkgPair;
begin
Result:=TPkgPair.Create(Pkg1,Pkg2);
Add(Result);
end;
function TPkgPairTree.AddPairIfNotExists(Pkg1, Pkg2: TLazPackage): TPkgPair;
begin
Result:=FindPair(Pkg1,Pkg2,true);
if Result=nil then
Result:=AddPair(Pkg1,Pkg2);
end;
{ TPkgPair }
constructor TPkgPair.Create(Pkg1, Pkg2: TLazPackage);
begin
Package1:=Pkg1;
Package2:=Pkg2;
end;
function TPkgPair.ComparePair(Pkg1, Pkg2: TLazPackage): integer;
begin
Result:=Package1.Compare(Pkg1);
if Result=0 then
Result:=Package2.Compare(Pkg2);
end;
function TPkgPair.Compare(PkgPair: TPkgPair): integer;
begin
Result:=ComparePair(PkgPair.Package1,PkgPair.Package2);
end;
initialization
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);