Silence warning in QPrintDialog
Selecting "Print all" at page range options and accepting the dialog prints a warning message: "QPageRanges::addRange: 'from' and 'to' must be greater than 0" This happens because QPrintDialog tries to clear the printer's range collection by setting 'from' and 'to' to zero - which is an invalid page number. Avoid the validation method by setting QPageRanges directly to a clean instance. Change-Id: I23b66a97b36aa23506904e93688cb60a9d496bfb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9e1b49c53c50f97134515b9a924985a2a709c6f3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
baae2252d8
commit
be2a1c6250
@ -117,7 +117,7 @@ QT_USE_NAMESPACE
|
||||
// (Apologies to the folks with more than INT_MAX pages)
|
||||
if (dialog->fromPage() == 1 && dialog->toPage() == INT_MAX) {
|
||||
dialog->setPrintRange(QPrintDialog::AllPages);
|
||||
dialog->setFromTo(0, 0);
|
||||
printer->setPageRanges(QPageRanges());
|
||||
} else {
|
||||
dialog->setPrintRange(QPrintDialog::PageRange); // In a way a lie, but it shouldn't hurt.
|
||||
// Carbon hands us back a very large number here even for ALL, set it to max
|
||||
|
@ -796,13 +796,13 @@ void QPrintDialogPrivate::setupPrinter()
|
||||
// print range
|
||||
if (options.printAll->isChecked()) {
|
||||
p->setPrintRange(QPrinter::AllPages);
|
||||
p->setFromTo(0,0);
|
||||
p->setPageRanges(QPageRanges());
|
||||
} else if (options.printSelection->isChecked()) {
|
||||
p->setPrintRange(QPrinter::Selection);
|
||||
p->setFromTo(0,0);
|
||||
p->setPageRanges(QPageRanges());
|
||||
} else if (options.printCurrentPage->isChecked()) {
|
||||
p->setPrintRange(QPrinter::CurrentPage);
|
||||
p->setFromTo(0,0);
|
||||
p->setPageRanges(QPageRanges());
|
||||
} else if (options.printRange->isChecked()) {
|
||||
if (q->testOption(QPrintDialog::PrintPageRange)) {
|
||||
p->setPrintRange(QPrinter::PageRange);
|
||||
@ -811,7 +811,7 @@ void QPrintDialogPrivate::setupPrinter()
|
||||
// This case happens when CUPS server-side page range is enabled
|
||||
// Setting the range to the printer occurs below
|
||||
p->setPrintRange(QPrinter::AllPages);
|
||||
p->setFromTo(0,0);
|
||||
p->setPageRanges(QPageRanges());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,16 +147,16 @@ static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPri
|
||||
{
|
||||
if (pd->Flags & PD_SELECTION) {
|
||||
pdlg->setPrintRange(QPrintDialog::Selection);
|
||||
pdlg->setFromTo(0, 0);
|
||||
pdlg->printer()->setPageRanges(QPageRanges());
|
||||
} else if (pd->Flags & PD_PAGENUMS) {
|
||||
pdlg->setPrintRange(QPrintDialog::PageRange);
|
||||
pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
|
||||
} else if (pd->Flags & PD_CURRENTPAGE) {
|
||||
pdlg->setPrintRange(QPrintDialog::CurrentPage);
|
||||
pdlg->setFromTo(0, 0);
|
||||
pdlg->printer()->setPageRanges(QPageRanges());
|
||||
} else { // PD_ALLPAGES
|
||||
pdlg->setPrintRange(QPrintDialog::AllPages);
|
||||
pdlg->setFromTo(0, 0);
|
||||
pdlg->printer()->setPageRanges(QPageRanges());
|
||||
}
|
||||
|
||||
d->ep->printToFile = (pd->Flags & PD_PRINTTOFILE) != 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user