Access violation crashes on printing or previewing.
This sometimes occurs with printers that are remote or have large
complicated drivers that
take significant time to install.
The solution is to make sure that a valid printer is returned by
TPrinter.Create before proceeding.
This requires some new code in 'QRPrntr.pas' - outlined below.
The fix below is not entirely safe, in the event that no valid printer can
be created, the code might hang.
It is far more likely that TPrinter.create will throw an exception, though.
Many thanks to Ivan Haltakov of University of Sofia, Bulgaria for pointing this out.
Ivan says this cured problems with a Xerox P8ex printer, and network printers.
Changes to QRPrntr.pas
1. -----------------------------------------------------------
constructor TQRPrinter.Create;
begin
.. some code
FPrinterOK := Printer.Printers.Count > 0;
// QBS Tech 15/03/01
//make sure this call has time to complete...
aPrinter := nil;
aPrinter := TPrinter.Create;
while (aPrinter = nil) do
application.processmessages;
aPrinterSettings := TPrinterSettings.Create;
if PrinterOK then
.. code continues
|