summaryrefslogtreecommitdiff
path: root/dev-qt/qtprintsupport/files/qtprintsupport-5.13.2-no-cups.patch
blob: fe19baf4096bab83ace3479372d5c5fe3bf78703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 2ad3348031d8a622374920eac5bdd8fb9ecefcd7 Mon Sep 17 00:00:00 2001
From: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Date: Sat, 21 Dec 2019 19:57:45 +0100
Subject: 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>
---
 src/printsupport/dialogs/qprintdialog_unix.cpp | 8 +++++---
 1 file 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
-- 
cgit v1.2.1