diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2019-03-29 10:36:21 +0100 |
---|---|---|
committer | Heikki Halmet <heikki.halmet@qt.io> | 2019-04-01 11:56:42 +0000 |
commit | 3b7db8ac90ba36949cb4168f07cc8dace47758a7 (patch) | |
tree | c0d2d883f582a5a164dc334cb1cd3cb818b45b82 /tests | |
parent | 9e97d64ccd27adcb2053c90cfbcafaef68e53893 (diff) |
Fix assert/crash when creating QBrush with null QGradient
The QBrush constructor taking a QGradient would assert or crash if
passed a null (NoGradient) gradient. But it is not necessary for the
API to be as brittle as that: instead the result can simply be a null
QBrush object, i.e. the same as the default QBrush() constructor
creates (style == NoBrush).
This issue comes up now since with the recent introduction of
QGradient presets, the API opens for using QGradient directly, whereas
earlier, only the subclasses QLinearGradient etc. were to be used.
Fixes: QTBUG-74648
Change-Id: I1a9b1c4654e4375aa6684700a262cc0946851448
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index cd3eaa1478..ce6ce15767 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -345,6 +345,8 @@ void tst_QBrush::gradientPresets() QGradient invalidPreset(QGradient::Preset(-1)); QCOMPARE(invalidPreset.type(), QGradient::NoGradient); + QBrush brush(invalidPreset); + QCOMPARE(brush.style(), Qt::NoBrush); } void fill(QPaintDevice *pd) { |