I encountered incomprehensible behavior of Lazreport in different projects.
Usually do like this - I put the frReport1 component on the Datamodule (or on the form) and write the procedure:
procedure TdmReport.Print;
begin
frReport1.LoadFromFile('/data/test1.lrf');
frReport1.ShowReport;
end;
In some projects, this call passes without problems. But in other projects, the application crashes when ShowReport is called.
In this case, the following happens:
- No error messages are generated. The app just silently dies.
- The launch under the debbuger passes without errors. The required report opens without problems.
In my last big application, I put frReport1 on one of the forms and tried to call
frReport1.LoadFromFile('/data/test1.lrf');
frReport1.ShowReport;
And I got a silent crash of the application.
I did the following experiment:
1. Created a clean project with a main form and a Datamodule with frReport1 component. I have inserted the Print procedure into the Datamodule. And there is only one button on the main form that calls Print.
I launch the application, press the button on the main form - and everything works fine. The report opens.
2. I connect
the same Datamodule to my old application through the Project Inspector. In one of the forms, I call Print from the Datamodule and at the time of calling ShowReport, I get an application crash with familiar symptoms:
- No error messages are generated.
- The launch under the debager passes without errors.
I have little experience with Lazreport and I can't understand why in some cases the report opens, and in others the entire application crashes.
Please tell me what I'm doing wrong?
Ubuntu 20.04 + Lazarus 2.0.12