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 CLIENTHEIGHT = 225
CLIENTWIDTH = 799 CLIENTWIDTH = 799
ONCREATE = Form1Create ONCREATE = Form1Create
ONDESTROY = SearchResultsViewDestroy
HORZSCROLLBAR.PAGE = 800 HORZSCROLLBAR.PAGE = 800
VERTSCROLLBAR.PAGE = 226 VERTSCROLLBAR.PAGE = 226
LEFT = 280 LEFT = 280

View File

@ -3,13 +3,13 @@
LazarusResources.Add('TSearchResultsView','FORMDATA',[ LazarusResources.Add('TSearchResultsView','FORMDATA',[
'TPF0'#18'TSearchResultsView'#17'SearchResultsView'#7'CAPTION'#6#17'SearchRes' '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 +'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 +'Form1Create'#9'ONDESTROY'#7#24'SearchResultsViewDestroy'#18'HORZSCROLLBAR.P'
+'LEFT'#3#24#1#6'HEIGHT'#3#225#0#3'TOP'#3#133#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK' +'AGE'#3' '#3#18'VERTSCROLLBAR.PAGE'#3#226#0#4'LEFT'#3#24#1#6'HEIGHT'#3#225#0
+#15'ResultsNoteBook'#5'ALIGN'#7#8'albottom'#7'ANCHORS'#11#5'aktop'#6'akleft' +#3'TOP'#3#133#1#5'WIDTH'#3#31#3#0#9'TNOTEBOOK'#15'ResultsNoteBook'#5'ALIGN'#7
+#0#17'ONCLOSETABCLICKED'#7#30'ResultsNoteBookClosetabclicked'#7'OPTIONS'#11 +#8'albottom'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#17'ONCLOSETABCLICKED'#7#30'R'
+#19'nboshowclosebuttons'#12'nbomultiline'#0#6'HEIGHT'#3#185#0#3'TOP'#2'('#5 +'esultsNoteBookClosetabclicked'#7'OPTIONS'#11#19'nboshowclosebuttons'#12'nbo'
+'WIDTH'#3#31#3#0#0#7'TBUTTON'#14'btnSearchAgain'#7'ANCHORS'#11#5'aktop'#6'ak' +'multiline'#0#6'HEIGHT'#3#185#0#3'TOP'#2'('#5'WIDTH'#3#31#3#0#0#7'TBUTTON'#14
+'left'#0#7'CAPTION'#6#12'Search Again'#7'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLIC' +'btnSearchAgain'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#7'CAPTION'#6#12'Search A'
+'K'#7#19'btnSearchAgainClick'#4'LEFT'#2#8#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH' +'gain'#7'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLICK'#7#19'btnSearchAgainClick'#4'L'
+#2's'#0#0#0 +'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; fUpdating:= false;
end;//EndUpdate end;//EndUpdate
{Brings The results tab named APageName to front if APageName does not exist {Brings the results tab named APageName to front.
does nothing} If APageName does not exist, does nothing}
procedure TSearchResultsView.BringResultsToFront(APageName: string); procedure TSearchResultsView.BringResultsToFront(APageName: string);
begin begin
if PageExists(APageName) then if PageExists(APageName) then
@ -213,8 +213,6 @@ var
SearchObj: TLazSearch; SearchObj: TLazSearch;
begin begin
Result:= nil; Result:= nil;
SearchObj:= TLazSearch.Create;
SearchObj.SearchString:= SearchText;
if Assigned(ResultsNoteBook) then if Assigned(ResultsNoteBook) then
begin begin
With ResultsNoteBook do With ResultsNoteBook do
@ -228,6 +226,8 @@ begin
else else
begin begin
NewPage:= Pages.Add(ResultsName + SPACE); NewPage:= Pages.Add(ResultsName + SPACE);
SearchObj:= TLazSearch.Create;
SearchObj.SearchString:= SearchText;
fSearchObjectList.AddObject(ResultsName + SPACE, SearchObj); fSearchObjectList.AddObject(ResultsName + SPACE, SearchObj);
if NewPage > -1 then if NewPage > -1 then
begin begin
@ -389,15 +389,15 @@ begin
if i > -1 then if i > -1 then
begin begin
ThePage:= ResultsNoteBook.Page[i]; ThePage:= ResultsNoteBook.Page[i];
end;//if if Assigned(ThePage) then
if Assigned(ThePage) then
begin
TheListBox:= GetListBox(ThePage.PageIndex);
if Assigned(TheListBox) then
begin begin
i:= TheListBox.ItemIndex; TheListBox:= GetListBox(ThePage.PageIndex);
if i > -1 then if Assigned(TheListBox) then
result:= TheListBox.Items[i]; begin
i:= TheListBox.ItemIndex;
if i > -1 then
result:= TheListBox.Items[i];
end;//if
end;//if end;//if
end;//if end;//if
end;//GetSelectedText end;//GetSelectedText

View File

@ -274,6 +274,30 @@ type
PPkgDependency = ^TPkgDependency; 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 }
TPkgCompilerOptions = class(TBaseCompilerOptions) TPkgCompilerOptions = class(TBaseCompilerOptions)
@ -3220,6 +3244,80 @@ begin
Result:='$(TestDir)/publishedpackage/'; Result:='$(TestDir)/publishedpackage/';
end; 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 initialization
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames); PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);