Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

EStringListError: List index out of bounds (0). TStringList object range is 0..-1 in TppPrintPrevie

The list index out of bounds exception is occurring while the print preview form is showing. Unfortunately, I do not know which report as our application has numerous reports and the exception logging that I am using has not been capturing the name of the report. It does now, but I am hoping to get better insight before the exception occurs again.

EStringListError: List index out of bounds (0). TStringList object range is 0..-1.
------------------------------------------------------------------------------
Exception stack
{our .exe} ppThreadedPageCache.TppThreadedPageCache.ehExceptionTimer
{our .exe} Vcl.ExtCtrls.TTimer.Timer (Line 3244, "Vcl.ExtCtrls.pas" + 1)
{our .exe} System.Classes.StdWndProc (Line 18517, "System.Classes.pas" + 8)
------------------------------------------------------------------------------
Call stack for main thread
{ntdll.dll } ZwGetContextThread
------------------------------------------------------------------------------
Active Controls:
TppEdit ""
TppPrintPreview "ppPrintPreview"
------------------------------------------------------------------------------

The active control at the time of the exception is a TppEdit, which is defined in ppPreview.pas and is used for FKeyCatcher on the preview form. I don't see any code in ppPreview.pas that is referencing a TStringList by index. It may be in code in other units that is called from ppPreview. I'm still investigating.

The exception is being caught by TppThreadedPageCache. Does that always indicate that the exception is occurring during report generation?

Thanks

Comments

  • I would rather not set PreviewFormSettings.SinglepageOnly to True, as our users appreciate the capabilities of the newer preview.
  • Hi Jon,

    Which version of ReportBuilder and Delphi are you using?

    If this error does not occur with SinglePageOnly set to True, it is likely a threading conflict with your application. How are you accessing data for these reports? Are there any data-aware components connected to the same dataset as the report?

    Instead of using SinglePageOnly, you can now toggle the PreviewFormSettings.UseBackgroundThread property to generate the report in the main thread but retain all scrollable preview features.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 14
    RB Enterprise 22.03 Build 340, Delphi 11.3.
    I did not know about PreviewFormSettings.UseBackgroundThread. Thanks for the suggestion.

    I have not been able to reproduce the error myself, so I have not tested with SinglePageOnly. The exception has not occurred frequently for our users and may take a while to track down the cause.

    The issue has not been reported by a user. I only know about it from looking at exception logging. I do not know which report or whether it is occurring in multiple reports. My prior logging did not capture the report name.

    Some of our report screens have a grid that shows the data that will be used for the report. And the grid is linked to the same datasource / dataset as the report pipeline. I do call DisableControls / EnableControls during report generation.

    Yesterday, I modified TppThreadedPageCache.ehPageRequestThread_GenerateComplete and TppPageRequestThread.ExecuteReport to include the report name in the exception message.
Sign In or Register to comment.