Page 1 of 1
RVRVData.PAS - TRVFontInfoCacheFast.GetItems Bug
Posted: Thu Jun 18, 2009 2:56 pm
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.
Posted: Thu Jun 18, 2009 3:38 pm
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.
Posted: Thu Jun 18, 2009 3:42 pm
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.
Posted: Fri Jun 19, 2009 1:32 pm
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?
Posted: Fri Jun 19, 2009 6:51 pm
by Sergey Tkachenko
If you can create a simple project reproducing this problem, please send it to me.