* fixed index out of bounds error

git-svn-id: trunk@17668 -
This commit is contained in:
andrew 2008-12-03 03:06:54 +00:00
parent 27000278c6
commit 9a205e2a39
2 changed files with 12 additions and 6 deletions

View File

@ -279,7 +279,7 @@ begin
{$IFDEF CHM_DEBUG_TIME}
writeln('Stream read: ',FormatDateTime('hh:nn:ss.zzz', Now));
{$ENDIF}
with TContentsFiller.Create(fContentsTree, Stream, @fStopTimer) do begin
with TContentsFiller.Create(fContentsTree, Stream, @fStopTimer, fChm) do begin
DoFill(ParentNode);
Free;
end;
@ -291,7 +291,7 @@ begin
Stream := fchms.GetObject(fChm.IndexFile);
if Stream <> nil then begin
Stream.position := 0;
with TIndexFiller.Create(fIndexView, Stream) do begin;
with TIndexFiller.Create(fIndexView, Stream, fChm) do begin;
DoFill;
Free;
end;

View File

@ -56,6 +56,7 @@ type
private
fTreeView: TTreeView;
fStream: TStream;
fChm: TObject;
fText: TStringList;
fBranchCount: DWord;
fStop: PBoolean;
@ -67,7 +68,7 @@ type
function GetLIData(StartLine: Integer): TContentNode;
procedure FillULIndices;
public
constructor Create(ATreeView: TTreeView; AStream: TStream; StopBoolean: PBoolean);
constructor Create(ATreeView: TTreeView; AStream: TStream; StopBoolean: PBoolean; AChm: TObject);
procedure DoFill(ParentNode: TTreeNode);
@ -79,6 +80,7 @@ type
private
fListView: TListView;
fStream: TStream;
fChm: Tobject;
fText: TStringList;
function GetLIEnd(StartLine: Integer): Integer;
function GetNextLI(StartLine: Integer): Integer;
@ -88,7 +90,7 @@ type
function LineEndsUL(ALine: Integer): Boolean;
public
constructor Create(AListView: TListView; AStream: TStream);
constructor Create(AListView: TListView; AStream: TStream; AChm: TObject);
procedure DoFill;
end;
@ -137,6 +139,7 @@ begin
NodeInfo := GetLIData(X);
TreeNode := TContentTreeNode(fTreeView.Items.AddChild(ParentNode, NodeInfo.Name));
TreeNode.Url := NodeInfo.Url;
TreeNode.Data := fChm;
Inc(X, NodeInfo.LineCount);
except
// an exception can occur if we have closed the file while the toc is still being read
@ -220,12 +223,13 @@ begin
end;
constructor TContentsFiller.Create(ATreeView: TTreeView; AStream: TStream; StopBoolean: PBoolean);
constructor TContentsFiller.Create(ATreeView: TTreeView; AStream: TStream; StopBoolean: PBoolean; AChm: TObject);
begin
inherited Create;
fTreeView := ATreeView;
fStream := AStream;
fStop := StopBoolean;
fChm := AChm;
end;
procedure TContentsFiller.DoFill(ParentNode: TTreeNode);
@ -306,6 +310,7 @@ begin
fListView.Items.AddItem(Item);
Item.Caption := ItemName;
Item.Url := ItemUrl;
Item.Data := fChm;
ItemName := '';
ItemUrl := '';
end;
@ -333,11 +338,12 @@ begin
Result := Pos('</UL>', UpperCase(fText.Strings[ALine])) > 0;
end;
constructor TIndexFiller.Create(AListView: TListView; AStream: TStream);
constructor TIndexFiller.Create(AListView: TListView; AStream: TStream; AChm: TObject);
begin
inherited Create;
fListView := AListView;
fStream := AStream;
fChm := AChm;
end;
procedure TIndexFiller.DoFill;