Error in terminate ppPreview form
I have a TTimer on my main menu which will call Application.Terminate when
the application idle more than 30min. This statement frees all the active
child forms including my main menu, but I get Access Violation error if I
had run a report program (TppReport on a form) and leave the report
PreviewForm active. I have no problem if I only open the report program but
didn't preview the report. Any idea what is the problem? How to solve it?
Thanks in advance.
the application idle more than 30min. This statement frees all the active
child forms including my main menu, but I get Access Violation error if I
had run a report program (TppReport on a form) and leave the report
PreviewForm active. I have no problem if I only open the report program but
didn't preview the report. Any idea what is the problem? How to solve it?
Thanks in advance.
This discussion has been closed.
Comments
You may be freeing the report object before the Preview form is being
closed. Try closing the Preview form before you free anything else and see
if that makes a difference.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
object should free the preview form automatically when the application is
terminated? How should I free the Preview form and in which event?
I created a simple test application consisting of a TppReport, TTimer, and a
Button. When the button is pressed, the timer is enabled and the report
previews. Three seconds later the timer's OnTimer event fires and the
Application.Terminate command is executed. This seemed to work correctly
without an AV. Please give me the exact steps you took to get this AV or
perhaps send a small example demonstrating the behavior in .zip format to
support@digital-metaphors.com so I can recreate it on my machine.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Application.CreateForm(TReport1,Report1);
Report1.WindowState := wsMaximized;
Report1.ShowModal;
Report1.Release; {*** I changed this line, it was:-
FreeAndNil(Report1); ***}
I realized that when I use the FreeAndNil method and PreviewForm is opened,
I will get an AV, if PreviewForm is not open, no AV problem. It's my
mistake to use the FreeAndNil method for a form. Thank you very much.