summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHatem ElKharashy <[email protected]>2025-04-25 14:03:00 +0300
committerHatem ElKharashy <[email protected]>2025-05-21 12:15:22 +0300
commitcc9cec53830d64940bea2787be3da616117b64cf (patch)
tree044386dec5a48537e8d771d42995d17e59eba705
parent1a6e6d933d756758e0cb4ab66129bf274674e4e0 (diff)
Fix radial gradient unit parsingHEADdev
The QSvgHandler ignored the units for radial gradient, and tried to convert the parsed number directly to a double. Instead, convertToNumber function can be used to properly check for units. Fixes: QTBUG-126482 Pick-to: 6.9 6.8 6.5 Change-Id: I4632dcf041bcd0b1496853a0b009c97dd01092a6 Reviewed-by: Matthias Rauter <[email protected]> Reviewed-by: Robert Löhning <[email protected]>
-rw-r--r--src/svg/qsvghandler.cpp10
-rw-r--r--tests/baseline/data/bugs/radialGradientPercentage.svg11
2 files changed, 16 insertions, 5 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 59c5932..de2080e 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -3285,22 +3285,22 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
qreal ncx = 0.5;
qreal ncy = 0.5;
if (!cx.isEmpty())
- ncx = QSvgUtils::toDouble(cx);
+ ncx = convertToNumber(cx);
if (!cy.isEmpty())
- ncy = QSvgUtils::toDouble(cy);
+ ncy = convertToNumber(cy);
qreal nr = 0.5;
if (!r.isEmpty())
- nr = QSvgUtils::toDouble(r);
+ nr = convertToNumber(r);
if (nr <= 0.0)
return nullptr;
qreal nfx = ncx;
if (!fx.isEmpty())
- nfx = QSvgUtils::toDouble(fx);
+ nfx = convertToNumber(fx);
qreal nfy = ncy;
if (!fy.isEmpty())
- nfy = QSvgUtils::toDouble(fy);
+ nfy = convertToNumber(fy);
QRadialGradient *grad = new QRadialGradient(ncx, ncy, nr, nfx, nfy, 0);
grad->setInterpolationMode(QGradient::ComponentInterpolation);
diff --git a/tests/baseline/data/bugs/radialGradientPercentage.svg b/tests/baseline/data/bugs/radialGradientPercentage.svg
new file mode 100644
index 0000000..4338f15
--- /dev/null
+++ b/tests/baseline/data/bugs/radialGradientPercentage.svg
@@ -0,0 +1,11 @@
+<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <radialGradient id="gradient" cx="50%" cy="50%" r="85%" fx="50%" fy="50%">
+ <stop offset="0" stop-color="red"/>
+ <stop offset="0.3" stop-color="blue"/>
+ <stop offset="0.5" stop-color="green"/>
+ <stop offset="0.6" stop-color="black"/>
+ </radialGradient>
+ </defs>
+ <rect fill="url(#gradient)" width="200" height="200"/>
+</svg>