diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2010-12-01 10:24:44 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2010-12-20 15:14:26 (GMT) |
commit | ed2abc6f5d8b2fe9e819d473768767c11f9c83ba (patch) | |
tree | 5cd854fb4ff2a0e5b98d1cb5d31da30e4ca497cd | |
parent | 70fd5a220d966279eb66df08ad69539bb26d59cd (diff) | |
download | Qt-ed2abc6f5d8b2fe9e819d473768767c11f9c83ba.zip Qt-ed2abc6f5d8b2fe9e819d473768767c11f9c83ba.tar.gz Qt-ed2abc6f5d8b2fe9e819d473768767c11f9c83ba.tar.bz2 |
fix QPrinterInfo::defaultPrinter() on win
to not return a partially filled invalid printer info.
is the default printer couldn't be retrieved, return an invalid QPrinterInfo()
rather than a semi-invalid info
which has isDefault() == true and printerName() == "qt_no_printers"
Merge-request: 2516
Signed-off-by: axis
-rw-r--r-- | src/gui/painting/qprinterinfo_win.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp index 6adf5a4..f7b6874 100644 --- a/src/gui/painting/qprinterinfo_win.cpp +++ b/src/gui/painting/qprinterinfo_win.cpp @@ -84,16 +84,15 @@ QPrinterInfo QPrinterInfo::defaultPrinter() wchar_t buffer[256]; GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256); QString output = QString::fromWCharArray(buffer); + if (output != noPrinters) { + // Filter out the name of the printer, which should be everything before a comma. + QString printerName = output.split(QLatin1Char(',')).value(0); + QPrinterInfo printerInfo(printerName); + printerInfo.d_ptr->isDefault = true; + return printerInfo; + } - // Filter out the name of the printer, which should be everything before a comma. - bool noConfiguredPrinters = (output == noPrinters); - QString printerName = output.split(QLatin1Char(',')).value(0); - - QPrinterInfo printerInfo(printerName); - printerInfo.d_ptr->isDefault = true; - if (noConfiguredPrinters) - printerInfo.d_ptr->isNull = true; - return printerInfo; + return QPrinterInfo(); } QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const |