* fixed a possible chm compiler crash when a chm without .ht* files is created but full search is enabled.

git-svn-id: trunk@15573 -
This commit is contained in:
andrew 2010-07-15 03:28:43 +00:00
parent 2796b58cfd
commit 28041f3e3f
2 changed files with 17 additions and 1 deletions

View File

@ -86,11 +86,13 @@ type
FStream: TStream;
FWordList: TIndexedWordList;
FActiveLeafNode: TFIftiNode;
function GetHasData: Boolean;
procedure ProcessWords;
procedure WriteHeader(IsPlaceHolder: Boolean);
procedure WriteAWord(AWord: TIndexedWord);
public
procedure WriteToStream;
property HasData: Boolean read GetHasData;
constructor Create(AStream: TStream; AWordList: TIndexedWordList);
destructor Destroy; override;
end;
@ -261,6 +263,11 @@ begin
FActiveLeafNode.Flush(False); // causes the unwritten parts of the tree to be written
end;
function TChmSearchWriter.GetHasData: Boolean;
begin
Result := FActiveLeafNode <> nil;
end;
procedure TChmSearchWriter.WriteHeader ( IsPlaceHolder: Boolean ) ;
var

View File

@ -137,6 +137,7 @@ Type
FDefaultFont: String;
FDefaultPage: String;
FFullTextSearch: Boolean;
FFullTextSearchAvailable: Boolean;
FSearchTitlesOnly: Boolean;
FStringsStream: TMemoryStream; // the #STRINGS file
FTopicsStream: TMemoryStream; // the #TOPICS file
@ -970,7 +971,7 @@ begin
FSection0.WriteDWord(NToLE(DWord($0409)));
FSection0.WriteDWord(1);
FSection0.WriteDWord(NToLE(DWord(Ord(FFullTextSearch))));
FSection0.WriteDWord(NToLE(DWord(Ord(FFullTextSearch and FFullTextSearchAvailable))));
FSection0.WriteDWord(0);
FSection0.WriteDWord(0);
@ -1256,6 +1257,14 @@ begin
if FTopicsStream.Size = 0 then
Exit;
SearchWriter := TChmSearchWriter.Create(FFiftiMainStream, FIndexedFiles);
// do not add an empty $FIftiMain
if not SearchWriter.HasData then
begin
FFullTextSearchAvailable := False;
SearchWriter.Free;
Exit;
end;
FFullTextSearchAvailable := True;
SearchWriter.WriteToStream;
SearchWriter.Free;