Errors in Richviewedit DropFile

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 256
Joined: Fri Jun 18, 2021 3:07 pm

Errors in Richviewedit DropFile

Post by standay »

Hi,

If I try to clear the existing data in my rve in the dropfile method, I get errors reported by madexcept. Mostly it's a list index out of bounds I think from the tcustomrvdata.getitem call. Not sure what the problem is. All I have in dropfile now is

RichViewEdit1.Clear;
exit;

If I load a large file, it loads OK. But if I try to load a smaller file, it throws the error. It still loads and appears to work, but the errors are concerning.
If I load a smaller file, then a larger one it's OK. But as soon as I try to drop a smaller file onto a larger one it errors IF I scroll the larger file down a ways first. If I leave the larger file scrolled all the way up it will let me drop the smaller file.
If I remove any calls to Clear or ClearAll it will work, but just inserts the smaller file into the larger one which is not what I want.

I've tried InsertText and SetTextBuf and both have errors as above.

Any ideas appreciated.
Image7.png
Image7.png (79.2 KiB) Viewed 6405 times
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Errors in Richviewedit DropFile

Post by Sergey Tkachenko »

Can you give me the step-by-step instructions to reproduce this problem?
I believe it happens when inserting a text file in some specific place of a specific document.
standay
Posts: 256
Joined: Fri Jun 18, 2021 3:07 pm

Re: Errors in Richviewedit DropFile

Post by standay »

Sure...

Start new vcl project.
Add a trichviewedit.
Put "RichViewEdit1.Clear;" into DropFile method:

Code: Select all

procedure TForm1.RichViewEdit1DropFile(Sender: TCustomRichViewEdit;
  const FileName: TRVUnicodeString; var DoDefault: Boolean);
begin
  RichViewEdit1.Clear;
end;
Run app.
Drop a large text file into rve (I use a large PAS source file).
It should load and come up scrolled to the bottom of the file, with text selected. Leave the scroll where it is, and click in the rve to deselect text.
Drop a smaller text file into rve. Should see the list out of bounds error now.

Does not seem to be related to the insert function as such, but the Clear or ClearAll calls. All I know is I have not been able to fix it.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Errors in Richviewedit DropFile

Post by Sergey Tkachenko »

The component does not expect that you clear content in this event. It expects that you insert something at the caret position.
The exception occurs when the component tries to select the inserted content.
standay
Posts: 256
Joined: Fri Jun 18, 2021 3:07 pm

Re: Errors in Richviewedit DropFile

Post by standay »

OK. I worked around it by grabbing the filename from there, setting dodefault to false. Then I use the filename in my app idle and load there. So that will work.

Thanks for looking at it.
Post Reply