summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2017-06-06 23:46:06 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-06-07 14:49:13 +0000
commit0265a23bb02b68534bb3c86514cc93bc45a7444f (patch)
tree138a1b5c61ffbe12d82419cd78a117962e5ed4ef /src/widgets/kernel/qwidget.cpp
parente8ea1edd89729d4caeffa70dd8cf76a686294987 (diff)
Fix crash when calling QWidget::grab() on a QOpenGLWidget
By avoiding unneeded nested QPainters. Crash was: ASSERT: "s" in file /data/sources/qt/qt5/qtbase/src/gui/painting/qpaintengine_raster.cpp, line 2239 s was nullptr because the inner QPainter had called updateState(0), which is then dereferenced by the outer QPainter. Task-number: QTBUG-61036 Change-Id: I7aad648f805f1abac4d38dfbefa2292da8b52af4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index a2f3fa4a5f..6112d33974 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -5622,13 +5622,15 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
// punch a hole in the backingstore, so the texture will be visible.
if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) {
beginBackingStorePainting();
- QPainter p(q);
if (backingStore) {
+ QPainter p(q);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(q->rect(), Qt::transparent);
} else {
+ QImage img = grabFramebuffer();
+ QPainter p(q);
// We are not drawing to a backingstore: fall back to QImage
- p.drawImage(q->rect(), grabFramebuffer());
+ p.drawImage(q->rect(), img);
skipPaintEvent = true;
}
endBackingStorePainting();