From 7be079e1b1f13b58f5d69f86e5854edd25065532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 12 Nov 2009 14:47:42 +0100 Subject: Fixed a crash which could occur when perspective transforming QRegions. This made the padnavigator example crash. Task-number: QTBUG-5674 Reviewed-by: Gunnar --- src/gui/painting/qregion.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index b48b024..401773b 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3859,23 +3859,28 @@ QRegion::QRegion(const QRect &r, RegionType t) QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) { if (a.count() > 2) { - d = new QRegionData; - d->ref = 1; + QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), + fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); + if (qt_rgn) { + d = new QRegionData; + d->ref = 1; #if defined(Q_WS_X11) - d->rgn = 0; - d->xrectangles = 0; + d->rgn = 0; + d->xrectangles = 0; #elif defined(Q_WS_WIN) - d->rgn = 0; + d->rgn = 0; #endif - d->qt_rgn = PolygonRegion(a.constData(), a.size(), - fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); + d->qt_rgn = qt_rgn; + } else { + d = &shared_empty; + d->ref.ref(); + } } else { d = &shared_empty; d->ref.ref(); } } - QRegion::QRegion(const QRegion &r) { d = r.d; -- cgit v0.12