Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-4497

re-using a QPrinter on two different PS files result in incorrept printing.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.6.0
    • 4.5.3
    • GUI: Printing
    • None
    • 39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861

      When one uses a QPrinter multiple time, just changing the filename, the result is not correct.

      E.g.:
      QPrinter printer;
      for( lindex=0; lindex<list.count(); lindex++ )

      { printer.setOutputFileName(list.at(lindex)); QPainter p( &printer ); printPage(&printer, &p); }

      This task relate to the support task 00028864.

      Here is an autotest:
      diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
      index 14ab720..7559e4a 100644
      — a/tests/auto/qprinter/tst_qprinter.cpp
      +++ b/tests/auto/qprinter/tst_qprinter.cpp
      @@ -104,6 +104,7 @@ private slots:
      void errorReporting();
      void testCustomPageSizes();
      void printDialogCompleter();
      + void reusePrinterOnDifferentFiles();

      private:
      };
      @@ -959,5 +960,32 @@ void tst_QPrinter::printDialogCompleter()
      #endif
      }

      +void printPage(QPainter* painter)
      +

      { + painter->drawRect(10, 20, 30, 40); + painter->setPen(QPen(Qt::black,4)); + painter->drawRect(50, 60, 70, 80); +}

      +
      +void tst_QPrinter::reusePrinterOnDifferentFiles()
      +{
      + QPrinter printer;
      +

      { + printer.setOutputFileName("out1.ps"); + QPainter painter(&printer); + printPage(&painter); + }

      +

      { + printer.setOutputFileName("out2.ps"); + QPainter painter(&printer); + printPage(&painter); + }

      + QFile file1("out1.ps");
      + file1.open(QIODevice::ReadOnly);
      + QFile file2("out2.ps");
      + file2.open(QIODevice::ReadOnly);
      + QCOMPARE(file1.readAll(), file2.readAll());
      +}
      +
      QTEST_MAIN(tst_QPrinter)
      #include "tst_qprinter.moc"

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            poulain Benjamin Poulain (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes