diff options
author | John Layt <jlayt@kde.org> | 2012-05-25 19:28:37 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-29 00:41:46 +0200 |
commit | 5bd5f6ae69d749bc3adef58edc906b9fb46bb7a8 (patch) | |
tree | 48ae8bc756cba7cba683de6de12f01d3eaffc58d /src/printsupport/kernel | |
parent | d9a7f9488f7b8a3f7d5963bce88f375282979f25 (diff) |
QtPrintSupport: Change QPrinterInfo::defaultPrinter() behaviour
In Qt4 QPrinterInfo::defaultPrinter() has inconsistant behaviour
depending on the platform. On Mac and Unix if no default printer
is set in the system then the first available printer is returned.
but on Windows it returns a null QPrinterInfo.
Currently Qt5 returns the first printer on all platforms, but this
causes an inconsistency if you call isDefault() on the returned
QPrinterInfo.
The apidox is slightly ambiguous, but does seem to imply no printer
will be returned if no default is set.
The only place in Qt the public api is used is in QPrinter which is
coded expecting that defaultPrinter() may return null but for there
still to be availablePrinters().
Change-Id: I1bbef8cba259b7d51980a0199e9fd6d5466d921f
Reviewed-by: Teemu Katajisto <teemu.katajisto@digia.com>
Reviewed-by: John Layt <jlayt@kde.org>
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r-- | src/printsupport/kernel/qplatformprintersupport_qpa.cpp | 2 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinterinfo.cpp | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/printsupport/kernel/qplatformprintersupport_qpa.cpp b/src/printsupport/kernel/qplatformprintersupport_qpa.cpp index 35441df5fc..d2459dc91d 100644 --- a/src/printsupport/kernel/qplatformprintersupport_qpa.cpp +++ b/src/printsupport/kernel/qplatformprintersupport_qpa.cpp @@ -94,7 +94,7 @@ QPrinterInfo QPlatformPrinterSupport::defaultPrinter() if (printerInfo.isDefault()) return printerInfo; } - return printers.isEmpty() ? QPrinterInfo() : printers.front(); + return QPrinterInfo(); } QPrinterInfo QPlatformPrinterSupport::printerInfo(const QString &printerName) diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp index fbf2e4de33..dc60d7a50f 100644 --- a/src/printsupport/kernel/qprinterinfo.cpp +++ b/src/printsupport/kernel/qprinterinfo.cpp @@ -69,7 +69,12 @@ QPrinterInfoPrivate QPrinterInfoPrivate::shared_null; The return value should be checked using isNull() before being used, in case there is no default printer. + On some systems it is possible for there to be available printers + but none of them set to be the default printer. + \sa isNull() + \sa isDefault() + \sa availablePrinters() */ /*! |