Index out of bounds exception

General TRichView support forum. Please post your questions here
Post Reply
Splinter
Posts: 41
Joined: Mon Aug 29, 2005 6:08 pm

Index out of bounds exception

Post by Splinter »

Hi Sergey,

I can consistently reproduce this error in RichViewEdit 1.9.15.1, Delphi 5 if you:

type some text
insert a table
in the LAST cell of the table insert an animated gif image (using Anders component)
type some text under the table

Then, when you press backspace to delete the text, when you reach the beginning of the line and go to the previous line, the exception occurs.

I've emailed you an attachment containing a cut-down sample application that reproduces this error. Just right click the RVE and choose 'Import file' and import the attached .RVF file, then just press backspace a few times from the bottom to get the error.

I could not reproduce this problem in RichViewActions and wonder if it is related to use of unicode in my app?

Thanks for any suggestions :-)
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, I can confirm it.
But this exception is not dangerous, because it is catched by TRichView code (you will not notice it when running outside Delphi IDE).
But for any case, I modified my copy of code to avoid this exception.
Splinter
Posts: 41
Joined: Mon Aug 29, 2005 6:08 pm

Post by Splinter »

Thanks Sergey,

Yes in the cut-down app I emailed you, the exception does seem to be captured. However, I discovered this problem when in my main app the problem occured and in red letters in the top left corner of the RVE was the message 'Error: List index out of bounds (7)'. So I think in some circumstances it was not captured so well :( . I have emailed you two screen shots 'before' and 'after' displaying this error.

Do you think your fix will have captured this more serious one as well? Which version number will this be released in?

:D
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I can explain where you need to modify.

Change 1, CRVFData.pas.
Beginning of DrawItem2Item must be:

Code: Select all

procedure TCustomRVFormattedData.DrawItem2Item(DrawItemNo, DrawItemOffs: Integer;
                             var ItemNo, ItemOffs: Integer);
var dli: TRVDrawLineInfo;
begin
  ItemNo := -1;
  if (DrawItemNo = -1) or (DrawItemNo>=DrawItems.Count) then exit;
Change 2, RVTable.pas, change TRVTableItemInfo.CompletelySelected

Code: Select all

function TRVTableItemInfo.CompletelySelected: Boolean;
var SN,EN,SO,EO,No: Integer;
begin
  Result := Rows.FMainRVData is TCustomRVFormattedData;
  if not Result then
    exit;
  if rvstCompletelySelected in Rows.FMainRVData.State then
    exit;
  TCustomRVFormattedData(Rows.FMainRVData).GetSelectionBounds(SN,SO,EN,EO,True);
  Result := (SN>=0) and (EN>=0);
  if not Result then
    exit;
  No := GetMyItemNo;
  Result := ((No>SN) or ((No=SN) and (SO=0))) and
            ((No<EN) or ((No=EN) and (EO=1)));
end;
Splinter
Posts: 41
Joined: Mon Aug 29, 2005 6:08 pm

Post by Splinter »

Works perfectly. Thanks. :mrgreen:
Post Reply