From d559b1678a11f703ca4dc2e88671805bffd4a68c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 10 Mar 2017 10:32:57 +0100 Subject: [printergui] Handle NULL ppd in handleTrustedPrint() --- src/maingui/printergui.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/maingui/printergui.cpp b/src/maingui/printergui.cpp index 8d094e3..4cd1192 100644 --- a/src/maingui/printergui.cpp +++ b/src/maingui/printergui.cpp @@ -112,6 +112,8 @@ void PrinterGui::initializeUI() h.append("Standort"); ui->printerList->setHeaderLabels(h); + // Hide trusted print by default + handleTrustedPrint(NULL); // Fill treewidget with data from cups dests; cups_dest_t *dest = dests; for (int i = num_dests; i > 0; ++dest, --i) { @@ -182,18 +184,19 @@ void PrinterGui::handleTrustedPrint(ppd_file_t *ppd) static QRegExpValidator sevenNum(QRegExp("^[0-9]{1,7}$")); QRegExpValidator *pwValidator = NULL; - - for (ppd_option_t *o = ppdFirstOption(ppd); o != NULL; o = ppdNextOption(ppd)) { - if (strcmp(o->keyword, "UseSecure") == 0) { - supported = true; - enabled = (strcmp(o->defchoice, "On") == 0); - } else if (strcmp(o->keyword, "SecuredPassword") == 0) { - pwProperty = o->keyword; - pwValidator = &sevenNum; - } else if (strcmp(o->keyword, "UserPassword") == 0) { - if (pwProperty.isEmpty()) { + if (ppd != NULL) { + for (ppd_option_t *o = ppdFirstOption(ppd); o != NULL; o = ppdNextOption(ppd)) { + if (strcmp(o->keyword, "UseSecure") == 0) { + supported = true; + enabled = (strcmp(o->defchoice, "On") == 0); + } else if (strcmp(o->keyword, "SecuredPassword") == 0) { pwProperty = o->keyword; pwValidator = &sevenNum; + } else if (strcmp(o->keyword, "UserPassword") == 0) { + if (pwProperty.isEmpty()) { + pwProperty = o->keyword; + pwValidator = &sevenNum; + } } } } -- cgit v1.2.3-55-g7522