diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2009-10-05 00:45:54 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2009-10-05 00:45:54 +0200 |
commit | 5ed35d4b991a203f187104c259296a284b5cc502 (patch) | |
tree | cd4495072164594aaa4863e49628bf955952b28b | |
parent | 83ae44c83c990278b31124e582804af386c35ca4 (diff) | |
download | fpGUI-5ed35d4b991a203f187104c259296a284b5cc502.tar.xz |
Fixed AV when using search.
-rw-r--r-- | src/TextSearchQuery.pas | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/TextSearchQuery.pas b/src/TextSearchQuery.pas index 2a5697b5..d4a7a6ba 100644 --- a/src/TextSearchQuery.pas +++ b/src/TextSearchQuery.pas @@ -25,6 +25,8 @@ Type end; TTextSearchQuery = class + private + procedure Cleanup; protected Terms: TList; function GetTerm( Index: longint ): TSearchTerm; @@ -50,6 +52,7 @@ var CombineMethod: TSearchTermCombineMethod; lTerm: TSearchTerm; begin + inherited Create; Terms := TList.Create; try RemainingSearchString := Uppercase( SearchString ); @@ -84,24 +87,40 @@ begin Terms.Add( lTerm ); end; except - Destroy; // clean up - raise; // reraise exception + while Terms.Count > 0 do + begin + lTerm := TSearchTerm(Terms.Last); + Terms.Remove(lTerm); + lTerm.Free; + end; + Terms.Free; + raise; // reraise exception end; end; destructor TTextSearchQuery.Destroy; +begin + Cleanup; + inherited Destroy; +end; + +procedure TTextSearchQuery.Cleanup; var i: TSearchTerm; begin - while Terms.Count > 0 do + if Assigned(Terms) then begin - i := TSearchTerm(Terms.Last); - Terms.Remove(i); - i.Free; + while Terms.Count > 0 do + begin + i := TSearchTerm(Terms.Last); + Terms.Remove(i); + i.Free; + end; + + // DestroyListObjects( Terms ); + Terms.Free; end; -// DestroyListObjects( Terms ); - Terms.Destroy; end; function TTextSearchQuery.GetTerm( index: longint ): TSearchTerm; |