summaryrefslogtreecommitdiffstats
path: root/src/printsupport/dialogs
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-21 19:57:45 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-23 16:05:48 +0100
commit2ad3348031d8a622374920eac5bdd8fb9ecefcd7 (patch)
tree3f0d722712e107b43f430c77b0805f00f03f1907 /src/printsupport/dialogs
parente0b9beb63dead017b6849ebcaa91c04a57f955c6 (diff)
QPrintDialog: don't access dangling pointer when cups is disabled
When no cups support is available, ui.pagesRadioButton is destroyed in QPrintDialogPrivate::init() but was accessed later on. Fix it by moving the cups check one line above. Fixes: QTBUG-80945 Change-Id: Ieb062b39e1461f39665ef612dfea1d7757274b7e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/printsupport/dialogs')
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index c7328d9732..7bbf137977 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -637,8 +637,10 @@ void QPrintDialogPrivate::init()
options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
#else
- for (int i = options.pagesLayout->count() - 1; i >= 0; --i)
- delete options.pagesLayout->itemAt(i)->widget();
+ delete options.pagesRadioButton;
+ delete options.pagesLineEdit;
+ options.pagesRadioButton = nullptr;
+ options.pagesLineEdit = nullptr;
#endif
top->d->setOptionsPane(this);
@@ -727,12 +729,12 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
else
options.pageSetCombo->setEnabled(true);
+#if QT_CONFIG(cups)
// Disable complex page ranges widget when printing to pdf
// It doesn't work since it relies on cups to do the heavy lifting and cups
// is not used when printing to PDF
options.pagesRadioButton->setEnabled(outputFormat != QPrinter::PdfFormat);
-#if QT_CONFIG(cups)
// Disable color options on main dialog if not printing to file, it will be handled by CUPS advanced dialog
options.colorMode->setVisible(outputFormat == QPrinter::PdfFormat);
#endif