Windows Printer: Handle no default printer case
GetDefaultPrinter can return ERROR_FILE_NOT_FOUND. In that case just return a empty string. Task-number: QTBUG-53290 Change-Id: Ib0e28b3425d100bc185d1d8827dc6b7fd90cbbeb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
06b5e4d706
commit
e7471da4d6
@ -449,7 +449,9 @@ QStringList QWindowsPrintDevice::availablePrintDeviceIds()
|
||||
QString QWindowsPrintDevice::defaultPrintDeviceId()
|
||||
{
|
||||
DWORD size = 0;
|
||||
GetDefaultPrinter(NULL, &size);
|
||||
if (GetDefaultPrinter(NULL, &size) == ERROR_FILE_NOT_FOUND)
|
||||
return QString();
|
||||
|
||||
QScopedArrayPointer<wchar_t> name(new wchar_t[size]);
|
||||
GetDefaultPrinter(name.data(), &size);
|
||||
return QString::fromWCharArray(name.data());
|
||||
|
Loading…
Reference in New Issue
Block a user