summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/printme/printhandler.h
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2021-08-27 13:24:42 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-30 21:52:29 +0000
commitcd1ddd3450e2e9d708cecd814cc356a44fe0282a (patch)
tree87e8d65270e1425a2db9aead0a6bc00634536f28 /examples/webenginewidgets/printme/printhandler.h
parent7f31695d2b8c1276cb93b4e94edaf740ddd8f90c (diff)
Fix crash in PrintMe example
Connecting the same lambda slot multiple times to QWebEngineView::printFinished causes crash. Fix this by a minor refactoration and adjust documentation. Task-number: QTBUG-95339 Change-Id: I03b6a1ff6244c80073248182a905d8d664fdd326 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit e3679c1a8316b70fb6b8a0f85fdd06443de8b409) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/webenginewidgets/printme/printhandler.h')
-rw-r--r--examples/webenginewidgets/printme/printhandler.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/webenginewidgets/printme/printhandler.h b/examples/webenginewidgets/printme/printhandler.h
index 663fd73d6..ca5d0b03b 100644
--- a/examples/webenginewidgets/printme/printhandler.h
+++ b/examples/webenginewidgets/printme/printhandler.h
@@ -51,7 +51,9 @@
#ifndef PRINTHANDLER_H
#define PRINTHANDLER_H
+#include <QEventLoop>
#include <QObject>
+#include <QPrinter>
QT_BEGIN_NAMESPACE
class QPainter;
@@ -70,9 +72,12 @@ public slots:
void print();
void printPreview();
void printDocument(QPrinter *printer);
+ void printFinished(bool success);
private:
QWebEngineView *m_view = nullptr;
+ QPrinter m_printer;
+ QEventLoop m_waitForResult;
bool m_inPrintPreview = false;
};