path: root/tests
diff options
authorJohn Layt <>2013-11-23 19:52:34 +0100
committerThe Qt Project <>2013-11-29 15:59:00 +0100
commite8a45152b5e2e99e757e91a5d42a6dce609ff583 (patch)
treead9b801d10b236a4d74caa58b270475b7f25b85b /tests
parent7079f1121325cedfb59c753870bd227a897ce6c7 (diff)
QPrinter - Fix OutputFormat when no printers
Currently the QPrinter constructor, setOutputFormat() and setPrinterName() make bad assumptions about the availability of printers when configuring NativeFormat which can lead to inconsistent print engine set-ups leading to crashes in the print dialog, especially on Windows where a valid DEVMODE is needed. This change cleans up the init and methods to ensure NativeFormat can only ever be set if we have both a valid plugin and a valid printer, if not the PdfFormat is used. One side-effect of this is that it is now impossible to set an invalid printer name via QPrinter (but still able to be done via QPrintEngine if really needed). Also if no default printer is set then use the first available one. This also fixes a bug where setting a new printer name on Windows reset all the saved settings. [ChangeLog][Important Behavior Changes] QPrinter no longer allows you to set an invalid printer name. Task-number: QTBUG-34345 Task-number: QTBUG-26008 Task-number: QTBUG-26430 Change-Id: I19737e4209d8c8df5817ea83246b3dd0c483ee85 Reviewed-by: Gunnar Sletta <>
Diffstat (limited to 'tests')
1 files changed, 1 insertions, 14 deletions
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 644cd33e5c..b8b4c00549 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -207,9 +207,6 @@ void tst_QPrinter::getSetCheck()
QCOMPARE(obj1.printerSelectionOption(), QString::fromLatin1("--option"));
- obj1.setPrinterName(QString::fromLatin1("myPrinter"));
- QCOMPARE(obj1.printerName(), QString::fromLatin1("myPrinter"));
// bool QPrinter::fontEmbeddingEnabled()
// void QPrinter::setFontEmbeddingEnabled(bool)
@@ -461,7 +458,7 @@ void tst_QPrinter::testNonExistentPrinter()
QPainter painter;
// Make sure it doesn't crash on setting or getting properties
- printer.setPrinterName("some non existing printer");
+ printer.printEngine()->setProperty(QPrintEngine::PPK_PrinterName, "some non existing printer");
@@ -709,9 +706,6 @@ void tst_QPrinter::valuePreservation()
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("","QTBUG-26430", Abort);
QCOMPARE(printer.collateCopies(), !status);
QCOMPARE(printer.collateCopies(), !status);
@@ -909,13 +903,6 @@ void tst_QPrinter::valuePreservation()
QCOMPARE(printer.printerName(), status);
- status = QString::fromLatin1("SuperDuperPrinter");
- printer.setPrinterName(status);
- printer.setOutputFormat(newFormat);
- QCOMPARE(printer.printerName(), status);
- printer.setOutputFormat(oldFormat);
- QCOMPARE(printer.printerName(), status);
// QPrinter::printerSelectionOption is explicitly documented not to be available on Windows.
#ifndef Q_OS_WIN