-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.8.3, 6.9.2, 6.10.0 Beta4
-
None
Description:
If QWebEngineView is deleted while a document is being printed, the application crashes.
Steps to Reproduce:
- Open a large document (e.g. a big PDF).
- Click the "Print" button.
- Start printing using view->print(printer).
- Delete the QWebEngineView before the printFinished signal is emitted. (e.g. by closing the window in the attached example)
Expected Result:
- Printing should stop gracefully, possibly with an error message in the console.
Actual Result:
- The application crashes.
For example code with debug output:
Widget::~Widget() { qDebug() << "~QWidget()"; qDebug() << "printer state" << printer_->printerState(); printer_->abort(); // has no effect } void Widget::printRequested() { qDebug() << "create QPrinter"; printer_ = new QPrinter(QPrinter::HighResolution); printer_->setOutputFormat(QPrinter::PdfFormat); printer_->setOutputFileName("/tmp/printer_example.pdf"); connect(view_, &QWebEngineView::destroyed, this, [this]() { qDebug() << "destroy QPrinter"; delete printer_; }, Qt::SingleShotConnection); connect(view_, &QWebEngineView::printFinished, this, [](bool ok) { qDebug() << "print done with" << ok; }, Qt::SingleShotConnection); view_->print(printer_); qDebug() << "start printing" << printer_->printerState(); }
Output:
create QPrinter start printing 0 ~QWidget() printer state 1 destroy QPrinter QPaintDevice: Cannot destroy paint device that is being painted .../webview_print_crash_test_001" terminated abnormally.
Full minimal example