Forum > LazReport

Lazreport kills the application unpredictably

(1/5) > >>

sydenis:
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:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TdmReport.Print;beginfrReport1.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

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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

dseligo:
Try to catch error like this, maybe it will shed some light on the issue:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---try  frReport1.LoadFromFile('/data/test1.lrf');except  on E: Exception do ShowMessage(E.Message);end; try  frReport1.ShowReport;except  on E: Exception do ShowMessage(E.Message);end;

sydenis:
Thank you, but no reaction.
The application continues to die silently despite two try ...except blocks

dseligo:

--- Quote from: sydenis on July 18, 2021, 07:41:59 pm ---Thank you, but no reaction.
The application continues to die silently despite two try ...except blocks

--- End quote ---

Are you sure it dies here?

See what you get from this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ShowMessage('1');    try      frReport1.LoadFromFile('/data/test1.lrf');    except      on E: Exception do ShowMessage(E.Message);    end;ShowMessage('2');         try      frReport1.ShowReport;    except      on E: Exception do ShowMessage(E.Message);    end;ShowMessage('3');
How complex is your report, what do you use in it? Do you have events attached, do you use scripts, do you use user datasets or DBdatasets?
It is strange you can't replicate your problem in new project. This suggests that the problem is somewhere else in your application.

Awkward:
One stupid thing: Are you sure what have all required units in "USES" part? For me, its: "LR_Class, LR_DSet, lrPDFExport, LR_e_img"
maybe you just miss one of unit there?

Navigation

[0] Message Index

[#] Next page

Go to full version