We hit an ERangeError in SRVPrint.GetPrinterInfo (SRVPrint.pas line 260) at form-load time, triggered via TSRVPrint.Loaded → UpdatePage → calculateSize → calculatePictureSize → GetPrinterInfo.
Root cause: on a machine where the default printer's CreateDC fails (offline/redirected printer, stopped spooler, broken driver), RV_GetPrinterDC returns a NULL HDC but the result is never checked. Every subsequent GetDeviceCaps then returns 0, so PixPerInchX/Y = 0, and line 260 computes round(0 / 0 * 25.4). With FPU exceptions masked, that yields Int64.MinValue, which overflows the Integer assignment under range checking.
Could you guard GetPrinterInfo against an invalid DC — e.g. if RV_GetPrinterDC returns 0 (or PixPerInchX/Y come back 0), fall back to the same defaults used in the "no printer" branch instead of dividing by them?
ERangeError in SRVPrint.GetPrinterInfo when default printer's CreateDC fails (division by zero PixPerInch)
-
Sergey Tkachenko
- Site Admin
- Posts: 18147
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: ERangeError in SRVPrint.GetPrinterInfo when default printer's CreateDC fails (division by zero PixPerInch)
Ok, it will be fixed in the next update.