summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTitta Heikkala <titta.heikkala@digia.com>2012-08-09 10:54:09 +0300
committerQt by Nokia <qt-info@nokia.com>2012-08-30 08:54:59 +0200
commit1cebd906af95e2c8ae37f1eae4a1c5019640b3b3 (patch)
tree4720835ce8fa3d0018a9a364b7d9994a5e470059
parentf7de5b09234e7dd735d91a7b332d841ca6c6fe53 (diff)
Ensure that printer orientation is preserved
After setting the printer name the initialization is no longer done for a printer with a name. Instead doReinit() method is called to preserve the orientation (set with setOrientation() method before calling setPrinterName()). Before the orientation was changed back to default when setPrinterName() method was called ignoring the orientation set. Updated also the autotest because the case: taskQTBUG4497_reusePrinterOnDifferentFiles() is no longer expected to fail on Windows. Task-number: QTBUG-26008 Change-Id: Ia6bc9ae14d79a646e61bfc97652f9f5af90738b3 Reviewed-by: Andy Shaw Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp17
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index e0eec585fa..39d7e48389 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1174,6 +1174,16 @@ void QWin32PrintEnginePrivate::doReinit()
if (state == QPrinter::Active) {
reinit = true;
} else {
+ if (!name.isEmpty()) {
+ HANDLE hCheckPrinter;
+ if (!OpenPrinter((LPWSTR)name.utf16(), (LPHANDLE)&hCheckPrinter, 0)) {
+ initialize();
+ return;
+ } else {
+ ClosePrinter(hCheckPrinter);
+ hCheckPrinter = 0;
+ }
+ }
resetDC();
initDevRects();
reinit = false;
@@ -1296,9 +1306,12 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
case PPK_PrinterName:
d->name = value.toString();
- if(d->name.isEmpty())
+ if (d->name.isEmpty()) {
d->queryDefault();
- d->initialize();
+ d->initialize();
+ } else {
+ d->doReinit();
+ }
break;
case PPK_Resolution:
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 9e08c594c4..4b4756bd5e 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -985,7 +985,9 @@ void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles()
QFile file2("out2.ps");
QVERIFY(file2.open(QIODevice::ReadOnly));
+#ifndef Q_OS_WIN
QEXPECT_FAIL("", "QTBUG-22562, QTBUG-22296", Abort);
+#endif
QCOMPARE(file1.readAll(), file2.readAll());
}