RVRVData.PAS - TRVFontInfoCacheFast.GetItems Bug

General TRichView support forum. Please post your questions here
Post Reply
ETKit
Posts: 3
Joined: Thu Jun 18, 2009 2:50 pm

RVRVData.PAS - TRVFontInfoCacheFast.GetItems Bug

Post by ETKit »

I find that if I attempt to edit the last line of text in a TRichViewEdit control an exception is thrown. This appears to happen because the Index passed to the TRVFontInfoCacheFast.GetItems method is equal to TRVFontInfoCacheFast.Count. I have fixed this for now by doing two things
  • Checking for Index < Count right at the start of the method.
  • Using Add in place of Put on line 1341 in the event that Index = Count
While this works, I need to understand why the exception is being thrown in the first place and whether this fix is acceptable. I'd appreciate any feedback on the matter.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The reason of this exception is quite obvious: your document contains a text item having incorrect StyleNo (valid values are from 0 to RVStyle.TextStyles.Count-1). Please check how your document is generated and fix this bug.
From the other hand, this situation must be handled by TRichView gracefully, without throwing an exception. This text must be formatted using RVStyle.TextStyles.InvalidItem. This is how it was in older version, but now this feature is lost. It will be fixed in the next update.
ETKit
Posts: 3
Joined: Thu Jun 18, 2009 2:50 pm

Post by ETKit »

Sergey Tkachenko wrote:The reason of this exception is quite obvious: your document contains a text item having incorrect StyleNo (valid values are from 0 to RVStyle.TextStyles.Count-1). Please check how your document is generated and fix this bug.
From the other hand, this situation must be handled by TRichView gracefully, without throwing an exception. This text must be formatted using RVStyle.TextStyles.InvalidItem. This is how it was in older version, but now this feature is lost. It will be fixed in the next update.
Thank you! I'll look into what is happening on the styles front.
ETKit
Posts: 3
Joined: Thu Jun 18, 2009 2:50 pm

Post by ETKit »

I looked at my code here as well as the various RVFOptions settings. Here is what I am doing

a. I use the same RichViewEdit component to load text from several text streams - only one is viewable and editable at any given time.
b. Whenever I load a new text stream I am clearing the RVE first.
c. Under RVFOptions I have the rvfoSaveTextStyles and rvfoSaveParaStyles flags set.
d. The two ...StyleReadMode properties are both set to rvf_sInsertMerge.

To save edited text I use SaveRVFToStream and to reload it I use LoadRVFFromStream. I call the Format method after loading.

I could be missing something but strikes me that I am doing everything right. Any thoughts?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you can create a simple project reproducing this problem, please send it to me.
Post Reply