How to prevent the "List index out of bounds" erro

General TRichView support forum. Please post your questions here
Post Reply
hdsupport
Posts: 10
Joined: Mon Sep 12, 2005 9:12 am

How to prevent the "List index out of bounds" erro

Post by hdsupport »

Hi,

We are having some trouble with the quoted error, and know that it has something to do with some unsupported codes/tags.

But now when we use the TRichView editor itself, to create a table and save it and then reload it, we also get the error. (We are using the DBEditor)

Besides it also appears when pasting from Word, which we have to convert in some way, or maybe prevent insertion of Word format.

I would like to know if there are any guidelines to how we should use the editor, without getting these errors? We have played around with the settings of the editor component, but we haven't found any solution yet.

We are considering moving back to plain text memo editor or richtext, in places where we need stability, and using trichview for more advanced text editing(e.g. letters).

We have used the trichview editor as a replacement for TRichText, and it is used throughout our application. But as it is more advanced and hence more difficult to control/tweak, we might switch back to the easier alternative.

So as I have mentioned above, if there are any general guidelines to how we can make the trichview editor stable, then this would be greatly appreciated.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This error appears when the program tries to get or set a list/collection item, and it uses an incorrect list index (negative or >= list.Count).
Any Delphi application uses a lot of lists and collections, so this error may happen everywhere.

If you can tell me how to reproduce this problem using existing TRichView demos, or in a simple project, please send this information to me.
If you can reliably reproduce it, the problem is solved by 99%.
hdsupport
Posts: 10
Joined: Mon Sep 12, 2005 9:12 am

thanks

Post by hdsupport »

Hi,

Thank you for replying.

Well, I probably have changed some property that I should not change, but I can't get the error to disappear. I will now be trying with a fresh form, and I will use a copy of the demo editor. Before this I used the richviewactions. For some reason I did always get the list index out of bounds error, when I added a table and reloaded.

I am using the DBRichViewEditor and the underlying database is DBISAM.

I will return after I have tried out my new form.

Kind regards Birger.
Rob
Posts: 52
Joined: Wed Sep 07, 2005 6:47 am

Post by Rob »

*** DELETED ***
hdsupport
Posts: 10
Joined: Mon Sep 12, 2005 9:12 am

New editor form

Post by hdsupport »

Hi,

I have now combined the demo editors 1 and 2 and have added AddictSpell checking. It seems to be working now.

I have copied the style component from the editor form, and have replaced all of the style components everywhere else with this one. This have helped as I no longer get the list index out of bounds error. I do not know which setting was causing the trouble.

So now I have multiple TDBRichView components that display memo fields from different tables. When the user doubleclicks the control, the data from the field is saved to a stream, and then loaded into the TRichViewEditor on the editor form.

I have a couple of questions that I will post in another thread.
hdsupport
Posts: 10
Joined: Mon Sep 12, 2005 9:12 am

Error again

Post by hdsupport »

Hi,

Unfortunately the error has reappeared. It goes wrong when I create a table(not paste). I can save the data to my dbisam database. Then when I open the form containing the tdbrichview, i get some access violations.

Also if I shut down the application and run it again, I am able to view the saved rvf data one time. But when I close the form and open it then I get the error again.

It seems like when the tdbrichview control is loaded the first time it is fresh. And then when it is shown again, something goes wrong.

I have traced the error to the unit RVFMisc, method RVFLoadControlbinary. Here an error occurs when it is trying to set the "ctrl" variable. The RVFLoadControlBinary is called by the method ReadRVFLine from the RVTable unit.

I will try to make a reproducable sample application.
wvd_vegt
Posts: 83
Joined: Tue Aug 30, 2005 7:39 am

Post by wvd_vegt »

Hi,

I get the error when reading a simple 4 letter document from a stream without any tables in it.

The error occurs in TCustomRichViewEdit.GetCurrentItemEx first line called by TrvActionTableCell.UPdateTarget.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) Using one TRVStyle for several richviews is dangerous. One of them can modify collection of styles, and references in other richviews become invalid. Editing operations add new styles, it's ok. But
- loading RVF file (or moving to another table record) replaces all styles;
- call of DeleteUnusedStyles may delete some styles; this function is called, for example, by TDBRichViewEdit if its AutoDeleteUnusedStyles=True, or by RichViewActions when loading/creating a new document.
Any of these 2 operations damages documents of all other RichViews linked to this RVStyle.
Using one common TRVStyle may be needed for some special tasks, normally it's highly recommended to use one TRVStyle for one TRichView

2) Failure in call GetCurrentItemEx may be because the document is not formatted (for example, loaded by LoadRVF without subsequent call of Format)
wvd_vegt
Posts: 83
Joined: Tue Aug 30, 2005 7:39 am

Post by wvd_vegt »

Hi,

Thanks, it was the Format that did the trick.

Why isn't Format called by default after loading?
hdsupport
Posts: 10
Joined: Mon Sep 12, 2005 9:12 am

style

Post by hdsupport »

Hi,

I do use multiple Style components. Each richview has got its own style component.

Maybe I should use the autodeleteunusedstyles, is it available in the DBrichview?

I call the format command after loading it from a stream into the RichViewEditor. But it is not needed, when using the DBRichView, right?

I have sent a sample application to your email address, i used my emailaddress: "birgerATwinlog.dk"
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Format is the slowest operation.
One may need to load multiple files in on TRichView, or to perform some processing of the loaded document (for example, mail merging).
Multiple calls of Format would slow down a program in these cases.

DBRichView and DBRichViewEdit call Format automatically when necessary (if you need document post-loading processing, use OnLoadDocument event)

If you use editing operations which can add new styles (for example, if you use RichViewActions), calling DeleteUnusedStyles when creating a new document or before loading an existent document is HIGHLY recommended.
DBRichViewEdit can do it automatically, if you set DBRichViewEdit.AutoDeleteUnusedStyles = True.
DBRichView does not have this property, but you can call DBRichView.DeleteUnusedStyles in DBRichView.OnNewDocument event.

I'll check your example tomorrow.
Post Reply