Forum > LazReport
Loading Report Masks Exceptions
(1/1)
SandyG:
Just getting back into doing some coding with Lazarus and FP.
Was making a simple app that that calculates a formula, then allows the user to print a report with the chart on it.
Everything seems to be working fine and when a floating point calculation happens that causes and exception it was normally picked up and shown while in the IOE or the compiled application.
As soon as I load a report with something like 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";}};} --- frReport1.LoadFromFile('MySimpleReport.lrf');
The application will no longer show any floating point exceptions, divide by zero, arccos(123.234) etc.
What is interesting is that IF I cause an exception in the application during runtime, they are caught! but this is ONLY UNTIL I call frReports LoadFromFile() then exceptions are masked.
Also it will not catch exception in a try/except block after the report is run.
I suspect the report is setting a mask on exceptions somewhere during runtime.
Any way to reset the exception mask once the report is loaded.
This is on Win 11 with Lazarus 3.0 (let me know what else you might need to know)
I'm a bit rusty so could be something I'm doing, but seems to be an issue with loading a report that is changing the exception handling chain or mask.
Thanks for any help!
Sandy
SandyG:
Maybe a better way to ask...
How does one typically modify the exception mask at runtime? Is this a possible solution?
Sandy
SandyG:
Dug a bit deeper and looked at the exception masks prior to the call to load the report...
It does trash the original settings and that doesn't seem like a good thing, seems like a bug and one that might not get noticed if you are using it and hoping to catch exceptions!
Will have to save and restore the state I guess
Here is what I saw dumping the mask before and after the call to load the report...
SandyG:
To close this out...
I saved the state an restore after the operation. This is my hack code -
--- 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 TMainDataEntry.PrintBtnClick(Sender: TObject);var em_before : TFPUExceptionMask; begin // Do the report. // Note that due to an issue in lazrepeorts the exception // mask is set to ignore all. This means you can't catch any // exceptions in the app. SO save it prior, do the report // restore it. em_before := GetExceptionMask; // Load the report on demand, and kill it when done frReport1.LoadFromFile('Doolittle.lrf'); frReport1.ShowReport; frReport1.Destroy; // restore the prior mask SetExceptionMask(em_before);end;
Thaddy:
That is not a hack, but the correct way to handle such issues.
Navigation
[0] Message Index