If CUPS has no default printer, set up the first one in list

Otherwise QCUPSSupport is instantiated without any printer being set up,
which leads to bugs and/or crashes in other parts using QCUPSSupport.

Change-Id: I1f4ddde5a28d6448d78aed856104ce8448e213c7
Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
Martin Klapetek 2013-10-18 15:19:19 +02:00 committed by The Qt Project
parent befe02aa6e
commit 229d92dc1e

View File

@ -144,11 +144,13 @@ QCUPSSupport::QCUPSSupport()
for (int i = 0; i < prnCount; ++i) {
if (printers[i].is_default) {
currPrinterIndex = i;
setCurrentPrinter(i);
break;
}
}
if (prnCount > 0)
setCurrentPrinter(currPrinterIndex);
#ifndef QT_NO_TEXTCODEC
cups_lang_t *cupsLang = _cupsLangGet(0);
codec = QTextCodec::codecForName(_cupsLangEncoding(cupsLang));