Errors when saving and loading RVF from stream

General TRichView support forum. Please post your questions here
Post Reply
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Errors when saving and loading RVF from stream

Post by martindholmes »

Hi there,

I'm trying to implement a crude undo system for operations which cannot be undone through the normal Undo functionality (for instance, after using functions like those described here: http://www.trichview.com/forums/viewtop ... =6701#6701

Basically, what I want to do is stream out the contents of a TRichViewEdit into a memory stream, then allow it to be streamed back if necessary. However, when I try to stream the data back into the memory stream, I get multiple instances of this:

EStringListError with message "List index out of bounds (-1)"

Here's the basic code. FBackupMemStream is a TMemoryStream created and destroyed by the TMarkRichView object in its constructor and destructor. RVE is a TRichViewEdit control.

procedure TMarkRichView.StashBackupStream;
begin
FBackupMemStream.Clear;
RVE.SaveRVFToStream(FBackupMemStream, False);
end;

procedure TMarkRichView.RestoreFromBackupStream;
begin
if FBackupMemStream.Size < 1 then
Exit;
RVE.Clear;
RVE.DeleteUnusedStyles(True, True, True);
RVE.Format;
FBackupMemStream.Position := 0;
RVE.LoadRVFFromStream(FBackupMemStream);
end;

In my test code, I call these two functions one after the other:

MRV.StashBackupStream;
//Do something...
MRV.RestoreFromBackupStream;


Can anyone see what might be causing the problem here?

All help appreciated,
Martin
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I'll answer when I return from vacations
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

Gentle bump for this question...
sigbert
Posts: 87
Joined: Fri Sep 02, 2005 4:47 am

Post by sigbert »

procedure TMarkRichView.RestoreFromBackupStream;
begin
if FBackupMemStream.Size < 1 then
Exit;
RVE.Clear;
RVE.DeleteUnusedStyles(True, True, True);
RVE.Format;
FBackupMemStream.Position := 0;
RVE.LoadRVFFromStream(FBackupMemStream);
RVE.Format;
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I just do not have Delphi here and I can only answer questions that do not require testing.
But it looks like sigbert's suggestion is correct
martindholmes
Posts: 131
Joined: Mon Aug 29, 2005 12:03 pm

Post by martindholmes »

That did it!

I keep forgetting that format call. Doh!

Cheers,
Martin
Post Reply