From cfbb0d2b407e45d652d18ecd940adbbc8b3ddddd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 7 Nov 2018 11:00:07 +0100 Subject: Avoid crashing with opaque opacity effect Fixes the crash, but doesn't fix the underlying bug. Task-number: QTBUG-60231 Change-Id: I5db9b151089b5c0e21e21443c77c725804d3059c Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 8c680560d4..da0d530990 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5858,7 +5858,11 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * pixmapOffset -= effectRect.topLeft(); - const qreal dpr = context->painter->device()->devicePixelRatioF(); + qreal dpr(1.0); + if (const auto *paintDevice = context->painter->device()) + dpr = paintDevice->devicePixelRatioF(); + else + qWarning("QWidgetEffectSourcePrivate::pixmap: Painter not active"); QPixmap pixmap(effectRect.size() * dpr); pixmap.setDevicePixelRatio(dpr); -- cgit v1.2.3