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>
This commit is contained in:
Christian Ehrlicher 2019-12-21 19:57:45 +01:00
parent e0b9beb63d
commit 2ad3348031

View File

@ -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