Page 1 of 1

Division by zero

Posted: Fri May 12, 2023 12:32 am
by Ceprotec
I am getting this error on a single report. I tried to create a demo, but I couldn't reproduce the error.

Code: Select all

main thread ($40e0):
00911150 +0068 NovoProcessoAuxiliarCeprotec.exe RVGrIn                        1613  +11 TRVGraphicInterface.ExpandSpacesInCoords
00c04e5a +046a NovoProcessoAuxiliarCeprotec.exe RVUniscribeGrIn                702  +58 TRVUniscribeGraphicInterface.GetGlyphDX
0090fc4b +003b NovoProcessoAuxiliarCeprotec.exe RVGrIn                         945   +1 TRVGraphicInterface.GetTextRangeCoords
0090fe25 +0055 NovoProcessoAuxiliarCeprotec.exe RVGrIn                        1029   +8 TRVGraphicInterface.ApplyTextRangeRegion
00c37709 +02c9 NovoProcessoAuxiliarCeprotec.exe RVStyle                      14423  +19 ApplySelectionRegion
00c37bda +0122 NovoProcessoAuxiliarCeprotec.exe RVStyle                      14496  +15 TRVStyle.DrawSelectedStyleText
00b64709 +0a31 NovoProcessoAuxiliarCeprotec.exe CRVFData                      7280 +153 DrawText
00b6726d +0959 NovoProcessoAuxiliarCeprotec.exe CRVFData                      8089 +164 TCustomRVFormattedData.PaintTo
0132aa22 +10fe NovoProcessoAuxiliarCeprotec.exe SclRView                     11635 +225 TSRichViewEdit.PaintPage
0132d8d6 +08a6 NovoProcessoAuxiliarCeprotec.exe SclRView                     12323 +158 TSRichViewEdit.UpdateRect
0134b271 +00e5 NovoProcessoAuxiliarCeprotec.exe SclRView                     22029  +13 TSRichViewEdit.DoWMRepaint
0134b183 +000f NovoProcessoAuxiliarCeprotec.exe SclRView                     22009   +1 TSRichViewEdit.WMRepaint
007cd8da +02be NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                  7591  +91 TControl.WndProc
007d2aa1 +0665 NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                 10644 +170 TWinControl.WndProc
0131e656 +0012 NovoProcessoAuxiliarCeprotec.exe SclRView                      8262   +1 TSRichViewEdit.WndProc
007d1fac +002c NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                 10321   +3 TWinControl.MainWndProc
00739518 +0014 NovoProcessoAuxiliarCeprotec.exe System.Classes               18517   +8 StdWndProc
752514bb +000b USER32.dll                                                               DispatchMessageW
008dae37 +00f3 NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                    11488  +23 TApplication.ProcessMessage
008dae62 +000a NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                    11510   +1 TApplication.ProcessMessages
01d3daba +00d2 NovoProcessoAuxiliarCeprotec.exe UFrmRelatoriosProtesto        1900  +22 TFrmRelatoriosProtesto.RVReportGenerator1DataQueryProgress
00ff3312 +003e NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             4704   +3 TCustomRVReportGenerator.ShowDataQueryProgress
00ff0df2 +0562 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3887 +107 TCustomRVReportGenerator.ProcessMainDataQuery
00ff0e10 +0580 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3889 +109 TCustomRVReportGenerator.ProcessMainDataQuery
00ff0f43 +06b3 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3917 +137 TCustomRVReportGenerator.ProcessMainDataQuery
00ff0f83 +06f3 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3920 +140 TCustomRVReportGenerator.ProcessMainDataQuery
00ff110a +014e NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3953  +21 TCustomRVReportGenerator.Execute
00ff116d +01b1 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3960  +28 TCustomRVReportGenerator.Execute
00ff11c7 +020b NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3969  +37 TCustomRVReportGenerator.Execute
00ff0fac +0018 NovoProcessoAuxiliarCeprotec.exe RVReportGenerator             3924   +1 TCustomRVReportGenerator.Execute
013a25c7 +001f NovoProcessoAuxiliarCeprotec.exe RVReportSRVGenerator            28   +2 GenerateReport
01d3d280 +03c4 NovoProcessoAuxiliarCeprotec.exe UFrmRelatoriosProtesto        1761  +68 TFrmRelatoriosProtesto.ActionGenerateReportExecute
01d3d386 +04ca NovoProcessoAuxiliarCeprotec.exe UFrmRelatoriosProtesto        1773  +80 TFrmRelatoriosProtesto.ActionGenerateReportExecute
007386df +000f NovoProcessoAuxiliarCeprotec.exe System.Classes               18008   +3 TBasicAction.Execute
007ad82a +0086 NovoProcessoAuxiliarCeprotec.exe Vcl.ActnList                   284  +19 TCustomAction.Execute
00738510 +0034 NovoProcessoAuxiliarCeprotec.exe System.Classes               17917   +6 TBasicActionLink.Execute
008bdd8b +0093 NovoProcessoAuxiliarCeprotec.exe Vcl.Menus                     2617  +17 TMenuItem.Click
008bf563 +0013 NovoProcessoAuxiliarCeprotec.exe Vcl.Menus                     3576   +5 TMenu.DispatchCommand
008d4268 +0038 NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                     6971   +5 TCustomForm.WMCommand
007cd8da +02be NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                  7591  +91 TControl.WndProc
007d2aa1 +0665 NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                 10644 +170 TWinControl.WndProc
008d0a38 +0710 NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                     5017 +222 TCustomForm.WndProc
008d0a53 +072b NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                     5018 +223 TCustomForm.WndProc
007d1fac +002c NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                 10321   +3 TWinControl.MainWndProc
007d1fc7 +0047 NovoProcessoAuxiliarCeprotec.exe Vcl.Controls                 10324   +6 TWinControl.MainWndProc
00739518 +0014 NovoProcessoAuxiliarCeprotec.exe System.Classes               18517   +8 StdWndProc
752514bb +000b USER32.dll                                                               DispatchMessageW
008dae37 +00f3 NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                    11488  +23 TApplication.ProcessMessage
008dae7a +000a NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                    11518   +1 TApplication.HandleMessage
008db1b9 +00d1 NovoProcessoAuxiliarCeprotec.exe Vcl.Forms                    11657  +27 TApplication.Run
01d65a94 +006c NovoProcessoAuxiliarCeprotec.exe NovoProcessoAuxiliarCeprotec    28   +6 initialization
75627d57 +0017 KERNEL32.DLL                                                             BaseThreadInitThunk

Re: Division by zero

Posted: Fri May 12, 2023 9:51 am
by Sergey Tkachenko
If you call Application.ProcessMessages in OnDataQueryProgress event, hide the editor before executing the report generator (Assign Visible = False).
Inside Application.ProcessMessages, the editor may be redrawn, but it is not ready yet, because it is in the middle of report creation.

Re: Division by zero

Posted: Fri May 12, 2023 12:46 pm
by Ceprotec
My project is an adaptation of the "ReportWorkshop\Demos\Delphi\FireDAC\ScaleRichViewReportEditor\DelphiUnicode" demo.

In the action "ActionGenerateReportExecute" the editor is hidden.

Code: Select all

srveResult.Visible := False;
    try
        DisableEnableCommands ( False ) ;
        lstMessages.Items.Clear;
        FExecuting := True;
        FAborted := False;
        ActionGenerateReport.Caption := RWA_GetS ( rwm_act_Abort ) ;
        ActionGenerateReport.Hint := RWA_GetS ( rwm_act_AbortH ) ;
        ActionGenerateReport.ImageIndex := 145;
        // generating
        if GenerateReport ( srveResult , RVReportGenerator1 ) then
            lstMessages.Items.Add ( RWA_GetS ( rwm_log_GenCompleted ) )
        else
            lstMessages.Items.Add ( RWA_GetS ( rwm_log_GenCompleted ) ) ;
    finally
        srveResult.Format;
        srveResult.Visible := True;
        FExecuting := False;
        ActionGenerateReport.Caption := RWA_GetS ( rwm_act_MakeReport ) ;
        ActionGenerateReport.Hint := RWA_GetS ( rwm_act_MakeReportH ) ;
        ActionGenerateReport.ImageIndex := 144;
        DisableEnableCommands ( PageControl1.ActivePageIndex < 2 ) ;
        DoneProgressBar;
    end;
Following your tip, I made a small adaptation in "RVReportGenerator1DataQueryProgress". I removed the last "Application.ProcessMessages;" and added them in "rvrpsExecutingQuery" and "rvrpsApplying".

Code: Select all

procedure TFrmRelatoriosProtesto.RVReportGenerator1DataQueryProgress (
    Sender : TCustomRVReportGenerator; Rule : TRVRowGenerationCustomRule;
    Cell : TRVReportTableCellData; Step : TRVReportProgressStep; Level ,
    Percent : Integer; var Proceed : Boolean ) ;
begin
    Proceed := not FAborted;
    if Level <> 1 then
        exit;
    case Step of
        rvrpsExecutingQuery :
            begin
                Application.Hint := RWA_GetS ( rwm_pgs_Executing ) ;
                Application.ProcessMessages;
            end;
        rvrpsApplying :
            begin
                if not ProgressBar1.Visible then
                begin
                    InitProgressBar;
                    Application.Hint := RWA_GetS ( rwm_pgs_Applying ) ;
                end;
                ProgressBar1.Position := Percent;
                Application.ProcessMessages;
            end;
        rvrpsFinished :
            begin
                DoneProgressBar;
                Application.Hint := '';
            end;
    end;

    //Application.ProcessMessages;
end;
So far it works, thanks.