summaryrefslogtreecommitdiffstats
path: root/src/maingui/printergui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/maingui/printergui.cpp')
-rw-r--r--src/maingui/printergui.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/maingui/printergui.cpp b/src/maingui/printergui.cpp
index 4cd1192..e8947d5 100644
--- a/src/maingui/printergui.cpp
+++ b/src/maingui/printergui.cpp
@@ -77,6 +77,11 @@ PrinterGui::PrinterGui(char *argv[], QWidget *parent) :
// ____________________________________________________________________________
PrinterGui::~PrinterGui()
{
+ QMap<QTreeWidgetItem*, ppd_file_t*>::const_iterator i = ppds.constBegin();
+ while (i != ppds.constEnd()) {
+ ppdClose(i.value());
+ }
+ ppds.clear();
cupsFreeDests(num_dests, dests);
free(this->user);
delete[] this->file;
@@ -274,7 +279,19 @@ void PrinterGui::on_printerList_currentItemChanged(QTreeWidgetItem *current, QTr
res = ::atoi(type);
}
- ppd_file_t *ppd = ppdOpenFile(cupsGetPPD2(CUPS_HTTP_DEFAULT, dest->name));
+ ppd_file_t *ppd = NULL;
+ if (ppds.contains(current)) {
+ ppd = ppds[current];
+ } else {
+ const char *ppdFile = cupsGetPPD2(CUPS_HTTP_DEFAULT, dest->name);
+ if (ppdFile == NULL) {
+ qDebug() << "cupsGetPPD2 for " << dest->name << " returned NULL: " << cupsLastErrorString();
+ } else {
+ ppd = ppdOpenFile(ppdFile);
+ qDebug() << dest->name << " has ppd " << ppdFile;
+ }
+ ppds.insert(current, ppd);
+ }
if (ppd != NULL) {
// Check color capabilities
//if (res & CUPS_PRINTER_COLOR) // No needed? Should just get disabled either way
@@ -283,9 +300,8 @@ void PrinterGui::on_printerList_currentItemChanged(QTreeWidgetItem *current, QTr
// TODO: Make it so this selection overrides what the document specifies
enableOptionSelection(ppd, knownPageSizeOptions, ui->cboPaperSize, ui->lblPaperSize, true);
handleTrustedPrint(ppd);
- ppdClose(ppd);
} else {
- qDebug() << "ppd is null"<< dest->name << cupsLastErrorString();
+ qDebug() << "ppd is null for "<< dest->name << "; cups last error: " << cupsLastErrorString();
}
// Check copy capabilities