From 3b7db8ac90ba36949cb4168f07cc8dace47758a7 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 29 Mar 2019 10:36:21 +0100 Subject: Fix assert/crash when creating QBrush with null QGradient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') 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) { -- cgit v1.2.3