trichview.com

trichview.support




Re: LoadRVFFromStream bug?


Return to index


Author

Message

John Ayres

Posted: 06/05/2003 23:17:21


"Yernar Shambayev" <[email protected]> wrote:

>

>This works:

>

>var

>  Stream: TFileStream;

>begin

>  Stream := TFileStream.Create('C:\readme.rvf', fmOpenRead);

>  try

>    Editor.LoadRVFFromStream(Stream);

>    Editor.Format;

>  finally

>    Stream.Free;

>  end;

>end;


This does not work at all.  LoadRVFFromStream calls a function that recursively

calls itself and ends in a stack overflow.  Examine the following code:


{------------------------------------------------------------------------------}

function TCustomRVData.LoadRVFFromStream(Stream: TStream;

                             var Color: TColor;

                             Background: TRVBackground;

                             Layout: TRVLayoutInfo):Boolean;

begin

  Clear;

  Result := InsertRVFFromStream(Stream,0, Color, Background, Layout, True);

end;

{------------------------------------------------------------------------------}

function TCustomRVData.InsertRVFFromStream(Stream: TStream; Index: Integer;

                             var Color: TColor;

                             Background: TRVBackground;

                             Layout: TRVLayoutInfo;

                             AllowReplaceStyles: Boolean):Boolean;

var Dummy: Integer;

    Dummy2,Dummy3: Boolean;

begin

  // AParaNo is used only if AppendMode=True

  Result := InsertRVFFromStream_(Stream, Index, -1, AllowReplaceStyles, False,

False,

                             Color, Background, Layout, Dummy, Dummy2,Dummy3);

end;

{------------------------------------------------------------------------------}

function TCustomRVData.InsertRVFFromStream_(Stream: TStream;

                             var Index: Integer;

                             AParaNo: Integer;

                             AllowReplaceStyles, AppendMode, EditFlag: Boolean;

                             var Color: TColor;

                             Background: TRVBackground;

                             Layout: TRVLayoutInfo;

                             var NonFirstItemsAdded: Integer;

                             var Protect, FullReformat: Boolean):Boolean;





Powered by ABC Amber Outlook Express Converter