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

Access violations OnDestroyForm

edited May 2008 in General
Hi,

I'm getting Access violations in the OnFormDestroy event handler. We had the
some problem with some other printing forms in the past and solved this by
setting the report objects last in the printing forms creation order (All
Pipeline and report objects reside on the same 'report printing form').
Now i'm in a situation where pipelines and reports reside on a seperate
datamodule. The 'report printing form' loads the different reports from the
datamodule as seperate pbSection subreports in the 'report printing form'
mainreports detailband using Template.LoadFromStream
Printing is ok but when i close the form the Access violations occur.
I traced the Access violations to TppCustomReport.Destroy depending on which
report gets loaded from the datamodule and printed the Access violation
occurs on FreeBandsAndGroups or FEngine.Free

FreeBandsAndGroups > detailband references nil tppDBText components
FEngine.Free > ClearDataPipelines FLookupDataPipelines references nil
TppDataPipeline components

What could be the cause off this?

Greetings,
Filip Moons

type
TFCT93200F = class(TFormSBProcDruk)
MyReport: TppReport; // Report to be printed
public
DefRptKAS: TDefReportKas; // DataModule holding loaded reports and
pipelines (TDefReportKas = class(TDataModule))
end;


Loading template code

procedure TFCT93200F.ReportLoad(Sender: TObject);
var
AStream: TMemoryStream;
ADefaultSubReport: TppSubreport;
ADefaultChildReport: TppChildReport;
ADefaultDetailSubReport: TppSubreport;
ADefaultDetailChildReport: TppChildReport;
begin
AStream := TMemoryStream.Create;
try
if cbOntwerp.ItemIndex = 1 then
DefRptKAS.rptNOT.Template.SaveToStream(AStream) // Ontwerp
ontvangstnota
else
DefRptKAS.rptKAS.Template.SaveToStream(AStream); // Ontwerp kasticket

// SubReport detailband hoofdrapport
ADefaultSubReport := TppSubReport.Create(Self);

// Add to the main report's detail band
ADefaultSubReport.Band := MyReport.DetailBand;

// Create the child report (parameters: main report)
ADefaultSubReport.CreateReport(MyReport);

// ChildRapport detail band hoofdrapport
ADefaultChildReport := TppChildReport(ADefaultSubReport.Report);

// Toewijzen default report
ADefaultChildReport.Template.LoadFromStream(AStream);

ADefaultSubReport.DataPipeline := DefRptKAS.ppFDKAS_ID;
ADefaultSubReport.PrintBehavior := pbSection;
ADefaultSubReport.ParentPrinterSetup := True;

ADefaultChildReport.DataPipeline := DefRptKAS.ppFDKAS_ID;
finally
FreeAndNil(AStream);
end;
end; {ReportLoad}


MyReport.Print;


// 'report printing form' OnFormDestory
procedure TFCT93200F.FormDestroy(Sender: TObject);
begin
// DataModule holding loaded reports and pipelines
if Assigned(DefRptKAS) then
begin
if DefRptKAS.DrBTWTabel.Active then
DefRptKAS.DrBTWTabel.Close;

// Close JIT pipelines
if DefRptKAS.QrDESCRIPTIONS.Active then
DefRptKAS.QrDESCRIPTIONS.Close;

if DefRptKAS.ppDESC_FDKAS_DOC.Active then
DefRptKAS.ppDESC_FDKAS_DOC.Close;

if DefRptKAS.ppDESC_FDKAS.Active then
DefRptKAS.ppDESC_FDKAS.Close;

if DefRptKAS.ppDESC_FDKAS.Active then
DefRptKAS.ppDESC_FDKAS.Close;

if DefRptKAS.ppDESC_LYDEB.Active then
DefRptKAS.ppDESC_LYDEB.Close;

if DefRptKAS.ppDESC_FDKAS_DET.Active then
DefRptKAS.ppDESC_FDKAS_DET.Close;

if DefRptKAS.ppFDCPY_ART.Active then
DefRptKAS.ppFDCPY_ART.Close;

if DefRptKAS.ppDESC_FDART.Active then
DefRptKAS.ppDESC_FDART.Close;

FreeAndNil(DefRptKAS);
end;

inherited FormDestroy(Sender);
end; {FormDestroy}

Comments

  • edited May 2008
    Hi Filip,

    This is not currently a known issue. Which version of ReportBuilder and
    Delphi are you using? Are you able to recreate this with a simple example
    application or perhaps one of the included demos? If so, please let me know
    how I can recreate it here and I'll try to track down the problem for you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2008
    Hi Nico,

    I'm able to recreate the AVS in a sample application using TClientDataSets,
    if that's allright for you . We are using ReportBuild 10.06 and Delphi 2006.
    Where do I send the sample application to?

    Greetings,
    Filip Moons

  • edited June 2008
    Hi Filip,

    I would first recommend updating your copy of ReportBuilder to the latest
    version (10.08) and testing with that. If you still experience the problem,
    please send the example to support@digital-metaphors.com in .zip format and
    I'll take a look at it for you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2008
    Hi Nico,

    For the moment we can't upgrade to the latest version, we will upgrade in a
    few months time. Email has been sent to support@digital-metaphors.com with
    the sample project attached which illustrates the problem

    Comment:
    All available reports are loaded into the rptDocument.DetailBand before the
    report is printed. We use the rptDocument.DetailBand.BeforeGenerate
    (DetailBandBeforeGenerate) in form 'TestRBu.pas' to select the report which
    will be printed the other reports loaded on the same detailband will be set
    to visible := false and their DataPipeline will be nilled. If you remove the
    code in the DetailBandBeforeGenerate event the AV doesn't occur in the
    OnDestroyForm.

    Greetings,
    Filip Moons


This discussion has been closed.