summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qprintengine_ps.cpp1
-rw-r--r--tests/auto/qprinter/tst_qprinter.cpp34
2 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp
index 772a30d..b740fbc 100644
--- a/src/gui/painting/qprintengine_ps.cpp
+++ b/src/gui/painting/qprintengine_ps.cpp
@@ -751,6 +751,7 @@ bool QPSPrintEngine::begin(QPaintDevice *pdev)
d->boundingBox = QRect();
d->fontsUsed = "";
d->hugeDocument = false;
+ d->simplePen = false;
setActive(true);
d->printerState = QPrinter::Active;
diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp
index d6df94b..3c05d90 100644
--- a/tests/auto/qprinter/tst_qprinter.cpp
+++ b/tests/auto/qprinter/tst_qprinter.cpp
@@ -108,6 +108,8 @@ private slots:
void testActualNumCopies();
+ void taskQTBUG4497_reusePrinterOnDifferentFiles();
+
private:
};
@@ -971,5 +973,37 @@ void tst_QPrinter::testActualNumCopies()
QCOMPARE(p.actualNumCopies(), 15);
}
+static void printPage(QPainter *painter)
+{
+ painter->setPen(QPen(Qt::black, 4));
+ painter->drawRect(50, 60, 70, 80);
+}
+
+void tst_QPrinter::taskQTBUG4497_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");
+ QVERIFY(file1.open(QIODevice::ReadOnly));
+
+ QFile file2("out2.ps");
+ QVERIFY(file2.open(QIODevice::ReadOnly));
+
+ QCOMPARE(file1.readAll(), file2.readAll());
+}
+
QTEST_MAIN(tst_QPrinter)
#include "tst_qprinter.moc"