bug and fix

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

bug and fix

Post by toolwiz »

In SclRView SetCurPage(PageNo : Integer)

Line# 8297

If you click on the page in SRVPageScroll1 (in the left bar) and nothing is loaded into the document, it GPFs.

You need to add a check:

if (DrawItemNo < 0) then exit;

after getting DrawItemNo and before looking up DrawItems[DrawItemNo]

eg:

if (checkRealTimeMode) or (PageNo < 1) or (PageNo > FPageCount) then exit;
DrawItemNo := PageStartDrawItemNo[PageNo - 1];
if (DrawItemNo < 0) then exit;
ItemNo := FRichViewEdit.RVData.DrawItems[DrawItemNo].ItemNo;
. . .


Same thing in Item2DrawItem (and probably several other places)


I'm trying to load a file into my app. It is loading into RVE, but for some reason it's not displaying. Something in my code is probably clearing things after it gets loaded. In any case, stuff isn't in a clean state, and there's one thing that's trying to select an item in the RVE that doesn't exist. So it's getting these errors that normally wouldn't be arising.

-David
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

replace:

Code: Select all

procedure TSRichViewEdit.SetCurPage(PageNo : Integer);
Var
      ItemNo, Offs, DrawItemNo : Integer;
      Item: TRVTableItemInfo;
begin
  if (checkRealTimeMode) or (PageNo < 1) or (PageNo > FPageCount) then
    exit;
  DrawItemNo := PageStartDrawItemNo[PageNo - 1];
  if (DrawItemNo < 0) or
     (DrawItemNo > FRichViewEdit.RVData.DrawItems.Count) then
    exit;
  ItemNo := FRichViewEdit.RVData.DrawItems[DrawItemNo].ItemNo;
  Offs := FRichViewEdit.RVData.DrawItems[DrawItemNo].Offs;
  VScrollPos := Round(RectPage(PageNo).Top - OffsetY) div FRichViewEdit.VSmallStep;
  if (PageStartTableItem[PageNo - 1] >= 0) then
    begin
      Item := TRVTableItemInfo(FRichViewEdit.RVData.GetItem(PageStartTableItem[PageNo - 1]));
      Item.Cells[PageStartTableRow[PageNo - 1], 0].Edit;
    end
  else
    RichViewEdit.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
  Update;
end;

Post Reply