aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-07-29 10:41:47 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-29 04:08:13 +0200
commitd08fb44d8f1414bbf519875fd872d742c41300ec (patch)
treea5b3009e1e8193a0badb7c8f2f28b737940b44b7 /src
parent44f82f2078897270622581e1c3f385d12c3aba42 (diff)
Correctly set ending path percent if none is provided.
Task-number: QTBUG-19818 Change-Id: I5377551d041b593864d56e4449c133deb47d3b45 Reviewed-on: http://codereview.qt.nokia.com/2358 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativepath.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/declarative/util/qdeclarativepath.cpp b/src/declarative/util/qdeclarativepath.cpp
index 3437e82d30..7b5d966719 100644
--- a/src/declarative/util/qdeclarativepath.cpp
+++ b/src/declarative/util/qdeclarativepath.cpp
@@ -208,6 +208,8 @@ void QDeclarativePath::endpoint(const QString &name)
}
}
+static QString percentString(QStringLiteral("_qfx_percent"));
+
void QDeclarativePath::processPath()
{
Q_D(QDeclarativePath);
@@ -227,6 +229,7 @@ void QDeclarativePath::processPath()
d->_path.moveTo(d->startX, d->startY);
QDeclarativeCurve *lastCurve = 0;
+ bool usesPercent = false;
foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
if (QDeclarativeCurve *curve = qobject_cast<QDeclarativeCurve *>(pathElement)) {
curve->addToPath(d->_path);
@@ -240,8 +243,9 @@ void QDeclarativePath::processPath()
interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value());
} else if (QDeclarativePathPercent *percent = qobject_cast<QDeclarativePathPercent *>(pathElement)) {
AttributePoint &point = d->_attributePoints.last();
- point.values[QLatin1String("_qfx_percent")] = percent->value();
- interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value());
+ point.values[percentString] = percent->value();
+ interpolate(d->_attributePoints.count() - 1, percentString, percent->value());
+ usesPercent = true;
}
}
@@ -251,6 +255,11 @@ void QDeclarativePath::processPath()
if (!last.values.contains(d->_attributes.at(ii)))
endpoint(d->_attributes.at(ii));
}
+ if (usesPercent && !last.values.contains(percentString)) {
+ d->_attributePoints.last().values[percentString] = 1;
+ interpolate(d->_attributePoints.count() - 1, percentString, 1);
+ }
+
// Adjust percent
qreal length = d->_path.length();
@@ -258,14 +267,14 @@ void QDeclarativePath::processPath()
qreal prevorigpercent = 0;
for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
const AttributePoint &point = d->_attributePoints.at(ii);
- if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QDeclarativePathPercent
+ if (point.values.contains(percentString)) { //special string for QDeclarativePathPercent
if ( ii > 0) {
qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) /
- (point.values.value(QLatin1String("_qfx_percent"))-prevpercent);
+ (point.values.value(percentString)-prevpercent);
d->_attributePoints[ii].scale = scale;
}
d->_attributePoints[ii].origpercent /= length;
- d->_attributePoints[ii].percent = point.values.value(QLatin1String("_qfx_percent"));
+ d->_attributePoints[ii].percent = point.values.value(percentString);
prevorigpercent = d->_attributePoints[ii].origpercent;
prevpercent = d->_attributePoints[ii].percent;
} else {