Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.7, 5.8.0
-
7257862fb2edfab0219d6cd45c83677049404f7d
Description
When a widget has QGraphicsOpacityEffect set to 1.0 and it contains child widgets with other graphic effects, the application first warns about invalid use of QPainter:
QPainter::begin: A paint device can only be painted by one painter at a time.
QPainter::translate: Painter not active
QPainter::worldTransform: Painter not active
and soon after the invalid painter is used, which leads to crash in QWidgetEffectSourcePrivate::pixmap().
The problem occurs only when the opacity is ~1.0 i.e. QGraphicsOpacityEffectPrivate::isFullyOpaque is true in /qtbase/src/widgets/effects/qgraphicseffect.cpp. Then in QGraphicsOpacityEffect::draw() the widget is drawn directly without going through a pixmap (see /qtbase/src/widgets/effects/qgraphicseffect.cpp, line 1198). In that case the same paint device (QImage) is used, but the painter is not shared and therefore a new painter is created for the same active paint device.
The attached example reproduces the problem. Running it leads to an immediate crash, but the crash can be prevented by changing the opacity to for example 0.99.
Attachments
Issue Links
- relates to
-
QTBUG-12170 Crash when set QGraphicsOpacityEffect opacity to 1.0 if child widgets have graphics effect
- Closed
- resulted in
-
QTBUG-66226 REG->5.9.4: QLabel using a QGraphicsOpacityEffect with opacity of 1.0 is not visible in a layout if it is not the topmost QLabel in the layout
- Closed