#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    Delphi quickreports


    I get an access violation with the composite reports. It previews fine. Can print it fine as well. As soon as I destroy it (free and nill it) I get an access violation. IOf I keep the form open I get an access violation as soon as I exit the program.

    Any ideas. Use to work on the previous version of quick reports (5.0)

    This is my code

    report1:= TqrDebtorRatelist.Create(Application);
    report2:= Treport2.Create(application);
    report2.report.Prepare;
    report2.QRCompositeReport1.Prepare;
    report2.QRCompositeReport1.Preview;
    Application.ProcessMessages;
    FreeandNil(report1);
    Report2.Release;
    report2 := nil;

    The composite report is on report 2. And on the composite report ONADDREPORTS events I have the following

    QRCompositeReport1.Reports.Add(Report2.Report);
    QRCompositeReport1.Reports.Add(Report1);


    I get the access violation on the freenandnil(report1). If I remove those codes then I get the violation on the MAIN FORM exit. If I preview them one by one it works fine.

    Please can you help me.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    I don't know enough about quick reports to offer specific advice. However, generically, it looks as if you
    are freeing something after it has already been freed.
    Either you may be doing it or Quick Reports may be freeing it after you.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    Re


    Thanks Clive.I thought its something like that. But what is weird if i leave the freeand nill out all is fine. But when i close the form on wich the report runs i get another access violation. Its just weird!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    They are always weird until you find the cause

    The issue with Access violations is that they do not manifest themselves when the problem
    is created. They only show up when you try to access the memory that has been compromised.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    350
    Rep Power
    7
    I haven't worked with quick reports either, but I'm not sure I understand your creation / destruction order, but I'm pretty sure you don't have to actually manually destroy the objects you create.

    You have

    report1:= TqrDebtorRatelist.Create(Application);
    report2:= Treport2.Create(Application);

    By making the application the owner, the application is responsible for freeing the object. You should be able to replace it with "Self" which would be a reference to the form, so that would make the form responsible to free the objects.

IMN logo majestic logo threadwatch logo seochat tools logo