diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-04-03 10:47:07 +0200 |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-04-03 11:50:06 +0200 |
commit | 6c2dd295b2ca2f9125fe072d035a3784ce748718 (patch) | |
tree | 565f5ba97690df7891a598c699e50e741444911e /src/svg/qsvghandler.cpp | |
parent | d684546573785ce40fb5de2b8b3aad88e9958709 (diff) | |
download | qt4-tools-6c2dd295b2ca2f9125fe072d035a3784ce748718.tar.gz |
Removed usage of NaN in SVG gradients.
Since there is no way to find out if gradient stops have been added to a
gradient, a gradient stop at NaN was earlier used in the SVG module to
mark the gradient as empty. This could cause floating point exceptions.
The usage of NaN has now been replaced by a boolean in
QSvgGradientStyle.
Duplicate entry "qxmlpatterns" was removed from auto.pro in the auto
test directory.
Task-number: 250146
Reviewed-by: Samuel
Diffstat (limited to 'src/svg/qsvghandler.cpp')
-rw-r--r-- | src/svg/qsvghandler.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 56dab5ffcf..18ba71c8ac 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2649,7 +2649,6 @@ static QSvgStyleProperty *createLinearGradientNode(QSvgNode *node, } QLinearGradient *grad = new QLinearGradient(nx1, ny1, nx2, ny2); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); parseBaseGradient(node, attributes, prop, handler); @@ -2783,7 +2782,6 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node, nfy = toDouble(fy); QRadialGradient *grad = new QRadialGradient(ncx, ncy, nr, nfx, nfy); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); @@ -2929,12 +2927,9 @@ static bool parseStopNode(QSvgStyleProperty *parent, QGradient *grad = style->qgradient(); offset = qMin(qreal(1), qMax(qreal(0), offset)); // Clamp to range [0, 1] - QGradientStops stops = grad->stops(); - // Check if the gradient is marked as empty (marked with one single stop at NaN). - if ((stops.size() == 1) && qIsNaN(stops.at(0).first)) { - stops.clear(); - grad->setStops(stops); - } else { + QGradientStops stops; + if (style->gradientStopsSet()) { + stops = grad->stops(); // If the stop offset equals the one previously added, add an epsilon to make it greater. if (offset <= stops.back().first) offset = stops.back().first + FLT_EPSILON; @@ -2950,6 +2945,7 @@ static bool parseStopNode(QSvgStyleProperty *parent, } grad->setColorAt(offset, color); + style->setGradientStopsSet(true); if (!colorOK) style->addResolve(offset); return true; |