From 12f7dd61c8dd4f1241382d91ceb2cceb0873f1d1 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Sun, 28 Feb 2010 04:37:37 +0000 Subject: [PATCH] - fix CUPS patch not to crash if currentPPD is NULL (#566304) --- qt-cups-1.patch | 92 ------------------- qt-everywhere-opensource-src-4.6.2-cups.patch | 84 +++++++++++++++++ qt.spec | 7 +- 3 files changed, 89 insertions(+), 94 deletions(-) delete mode 100644 qt-cups-1.patch create mode 100644 qt-everywhere-opensource-src-4.6.2-cups.patch diff --git a/qt-cups-1.patch b/qt-cups-1.patch deleted file mode 100644 index 013e3e2..0000000 --- a/qt-cups-1.patch +++ /dev/null @@ -1,92 +0,0 @@ -diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp -index 23f5831..f34277a 100644 ---- a/src/gui/dialogs/qprintdialog_unix.cpp -+++ b/src/gui/dialogs/qprintdialog_unix.cpp -@@ -569,6 +569,34 @@ void QPrintDialogPrivate::setTabs(const QList &tabWidgets) - void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups) - { - options.duplex->setEnabled(cups && cups->ppdOption("Duplex")); -+ -+ if(cups) -+ { -+ const ppd_option_t* duplex = cups->ppdOption("Duplex"); -+ if( duplex ) -+ { -+ // copy default ppd duplex to qt dialog -+ if( qstrcmp(duplex->defchoice, "DuplexTumble") == 0 ) -+ options.duplexShort->setChecked(true); -+ else if ( qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0 ) -+ options.duplexLong->setChecked(true); -+ else -+ options.noDuplex->setChecked(true); -+ } -+ -+ // set default color -+ if( cups->currentPPD()->color_device ) -+ options.color->setChecked(true); -+ else -+ options.grayscale->setChecked(true); -+ -+ // set collation -+ const ppd_option_t *collate = cups->ppdOption("Collate"); -+ if( collate ) -+ { -+ options.collate->setChecked(qstrcmp(collate->defchoice, "True")==0); -+ } -+ } - } - #endif - -diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp -index 4d2b50a..c7ab1b3 100644 ---- a/src/gui/painting/qprinter.cpp -+++ b/src/gui/painting/qprinter.cpp -@@ -627,6 +627,48 @@ QPrinter::QPrinter(PrinterMode mode) - && d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) { - setOutputFormat(QPrinter::PdfFormat); - } -+ -+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) -+ // fill in defaults from ppd file -+ QCUPSSupport cups; -+ -+ int printernum = -1; -+ for(int i = 0; i < cups.availablePrintersCount(); i++) -+ { -+ if( printerName().toLocal8Bit() == cups.availablePrinters()[i].name ) -+ printernum = i; -+ } -+ if( printernum >= 0 ) -+ { -+ cups.setCurrentPrinter(printernum); -+ -+ const ppd_option_t* duplex = cups.ppdOption("Duplex"); -+ if( duplex ) -+ { -+ // copy default ppd duplex to qt dialog -+ if( qstrcmp(duplex->defchoice, "DuplexTumble") == 0 ) -+ setDuplex(DuplexShortSide); -+ else if ( qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0 ) -+ setDuplex(DuplexLongSide); -+ else -+ setDuplex(DuplexNone); -+ } -+ -+ // set default color -+ if( cups.currentPPD()->color_device ) -+ setColorMode(Color); -+ else -+ setColorMode(GrayScale); -+ -+ // set collation -+ const ppd_option_t *collate = cups.ppdOption("Collate"); -+ if( collate ) -+ { -+ setCollateCopies(qstrcmp(collate->defchoice, "True")==0); -+ } -+ } -+ -+#endif - } - - /*! diff --git a/qt-everywhere-opensource-src-4.6.2-cups.patch b/qt-everywhere-opensource-src-4.6.2-cups.patch new file mode 100644 index 0000000..315adc1 --- /dev/null +++ b/qt-everywhere-opensource-src-4.6.2-cups.patch @@ -0,0 +1,84 @@ +diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp +--- qt-everywhere-opensource-src-4.6.2/src/gui/dialogs/qprintdialog_unix.cpp 2010-02-11 16:55:22.000000000 +0100 ++++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/dialogs/qprintdialog_unix.cpp 2010-02-28 04:34:16.000000000 +0100 +@@ -569,6 +569,32 @@ + void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups) + { + options.duplex->setEnabled(cups && cups->ppdOption("Duplex")); ++ ++ if (cups) { ++ const ppd_option_t* duplex = cups->ppdOption("Duplex"); ++ if (duplex) { ++ // copy default ppd duplex to qt dialog ++ if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0) ++ options.duplexShort->setChecked(true); ++ else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0) ++ options.duplexLong->setChecked(true); ++ else ++ options.noDuplex->setChecked(true); ++ } ++ ++ if (cups->currentPPD()) { ++ // set default color ++ if (cups->currentPPD()->color_device) ++ options.color->setChecked(true); ++ else ++ options.grayscale->setChecked(true); ++ } ++ ++ // set collation ++ const ppd_option_t *collate = cups->ppdOption("Collate"); ++ if (collate) ++ options.collate->setChecked(qstrcmp(collate->defchoice, "True")==0); ++ } + } + #endif + +diff -ur qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp +--- qt-everywhere-opensource-src-4.6.2/src/gui/painting/qprinter.cpp 2010-02-11 16:55:22.000000000 +0100 ++++ qt-everywhere-opensource-src-4.6.2-cups/src/gui/painting/qprinter.cpp 2010-02-28 04:55:15.000000000 +0100 +@@ -627,6 +627,44 @@ + && d_ptr->paintEngine->type() != QPaintEngine::MacPrinter) { + setOutputFormat(QPrinter::PdfFormat); + } ++ ++#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) ++ // fill in defaults from ppd file ++ QCUPSSupport cups; ++ ++ int printernum = -1; ++ for (int i = 0; i < cups.availablePrintersCount(); i++) { ++ if (printerName().toLocal8Bit() == cups.availablePrinters()[i].name) ++ printernum = i; ++ } ++ if (printernum >= 0) { ++ cups.setCurrentPrinter(printernum); ++ ++ const ppd_option_t* duplex = cups.ppdOption("Duplex"); ++ if (duplex) { ++ // copy default ppd duplex to qt dialog ++ if (qstrcmp(duplex->defchoice, "DuplexTumble") == 0) ++ setDuplex(DuplexShortSide); ++ else if (qstrcmp(duplex->defchoice, "DuplexNoTumble") == 0) ++ setDuplex(DuplexLongSide); ++ else ++ setDuplex(DuplexNone); ++ } ++ ++ if (cups.currentPPD()) { ++ // set default color ++ if(cups.currentPPD()->color_device) ++ setColorMode(Color); ++ else ++ setColorMode(GrayScale); ++ } ++ ++ // set collation ++ const ppd_option_t *collate = cups.ppdOption("Collate"); ++ if (collate) ++ setCollateCopies(qstrcmp(collate->defchoice, "True")==0); ++ } ++#endif + } + + /*! diff --git a/qt.spec b/qt.spec index d9d7976..c088e68 100644 --- a/qt.spec +++ b/qt.spec @@ -13,7 +13,7 @@ Summary: Qt toolkit Name: qt Epoch: 1 Version: 4.6.2 -Release: 2%{?dist} +Release: 3%{?dist} # See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details License: LGPLv2 with exceptions or GPLv3 with exceptions @@ -58,7 +58,7 @@ Patch53: qt-x11-opensource-src-4.5.0-fix-qatomic-inline-asm.patch # http://bugzilla.redhat.com/440673 Patch54: qt-x11-opensource-src-4.5.1-mysql_config.patch # http://bugs.kde.org/show_bug.cgi?id=180051#c22 -Patch55: qt-cups-1.patch +Patch55: qt-everywhere-opensource-src-4.6.2-cups.patch # security patches @@ -1005,6 +1005,9 @@ fi %changelog +* Sun Feb 28 2010 Kevin Kofler - 4.6.2-3 +- fix CUPS patch not to crash if currentPPD is NULL (#566304) + * Tue Feb 16 2010 Rex Dieter - 4.6.2-2 - macros.qt4: s/qt45/qt46/