From: "Lubomir I. Ivanov" <[email protected]> QPrinterInfo::availablePrinters() seems unreliable on Linux. It returns zero printers event if there are two printers listed in the print dialog on a stock Ubuntu - PDF printer and PS printer.
Not having a good check for the installed printers, forces us to check if the available page width and height are zero. If so we abort the profile or table prints. Signed-off-by: Lubomir I. Ivanov <[email protected]> --- i can't run my Qt5.3 32bit build on 32bit Windows XP SP2, it just starts to require a buch of DLLs from Windows 7's WOW64 emulator. that was the OS on which i've found that no installed printers results in bad behaviour hopefully the patch works as is there... --- qt-ui/printdialog.cpp | 18 ------------------ qt-ui/printdialog.h | 1 - qt-ui/printlayout.cpp | 7 +++++-- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index e8a323e..f8f06ae 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -66,24 +66,8 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f connect(quit, SIGNAL(activated()), parent, SLOT(close())); } -bool PrintDialog::checkForAvailablePrinters(void) -{ - QList<QPrinterInfo> list = QPrinterInfo::availablePrinters(); - if (!list.length()) { - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Critical); - msgBox.setText(tr("Subsurface cannot find installed printers on this system!")); - msgBox.setWindowIcon(QIcon(":subsurface-icon")); - msgBox.exec(); - return false; - } - return true; -} - void PrintDialog::previewClicked(void) { - if (!checkForAvailablePrinters()) - return; QPrintPreviewDialog previewDialog(&printer, this); connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *))); previewDialog.exec(); @@ -91,8 +75,6 @@ void PrintDialog::previewClicked(void) void PrintDialog::printClicked(void) { - if (!checkForAvailablePrinters()) - return; QPrintDialog printDialog(&printer, this); if (printDialog.exec() == QDialog::Accepted){ printLayout->print(); diff --git a/qt-ui/printdialog.h b/qt-ui/printdialog.h index b290218..32069a2 100644 --- a/qt-ui/printdialog.h +++ b/qt-ui/printdialog.h @@ -18,7 +18,6 @@ public: explicit PrintDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); private: - bool checkForAvailablePrinters(void); PrintOptions *optionsWidget; PrintLayout *printLayout; QProgressBar *progressBar; diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 1d34a06..899aa15 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -125,7 +125,7 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) int animationOriginal = prefs.animation_speed; struct dive *dive; - if (!total) + if (!total || !pageW || !pageH) return; // disable animations on the profile: @@ -308,7 +308,7 @@ void PrintLayout::printTable() struct dive *dive; int done = 0; // percents done int i, row = 0, progress, total = estimateTotalDives(); - if (!total) + if (!total || !pageW || !pageH) return; // create and setup a table @@ -383,6 +383,9 @@ void PrintLayout::printTable() total = model.rows - lastAccIndex; for (i = lastAccIndex; i < model.rows; i++) { rowH = table.rowHeight(i); + // skip huge rows. we don't support row spanning on multiple pages. + if (rowH >= pageH) + continue; accH += rowH; if (isHeading) { headingRowHeightD2 = rowH >> 1; -- 1.7.11.msysgit.0 _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
