summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel
diff options
context:
space:
mode:
authorMartin Klapetek <mklapetek@kde.org>2013-10-18 15:19:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-18 18:01:54 +0200
commit229d92dc1e20cd49ef8235c063df8fa948b3fcda (patch)
tree44dcf08e306651d1bc304d611a82207e3fabec97 /src/printsupport/kernel
parentbefe02aa6efeb351439112b27fc43e9866d6ea3d (diff)
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>
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r--src/printsupport/kernel/qcups.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 643ffef192..f14d4b8dd3 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -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));