aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qdeclarativepath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/util/qdeclarativepath.cpp')
-rw-r--r--src/quick/util/qdeclarativepath.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/quick/util/qdeclarativepath.cpp b/src/quick/util/qdeclarativepath.cpp
index 842b5465b7..52d0245ee0 100644
--- a/src/quick/util/qdeclarativepath.cpp
+++ b/src/quick/util/qdeclarativepath.cpp
@@ -513,6 +513,12 @@ void QDeclarativePath::createPointCache() const
}
}
+void QDeclarativePath::invalidateSequentialHistory() const
+{
+ Q_D(const QDeclarativePath);
+ d->prevBez.isValid = false;
+}
+
QPointF QDeclarativePath::sequentialPointAt(qreal p, qreal *angle) const
{
Q_D(const QDeclarativePath);
@@ -590,7 +596,7 @@ QPointF QDeclarativePath::backwardsPointAt(const QPainterPath &path, const qreal
if (pathLength <= 0 || qIsNaN(pathLength))
return path.pointAtPercent(0);
- const int firstElement = 0;
+ const int firstElement = 1; //element 0 is always a MoveTo, which we ignore
bool haveCachedBez = prevBez.isValid;
int currElement = haveCachedBez ? prevBez.element : path.elementCount();
qreal bezLength = haveCachedBez ? prevBez.bezLength : 0;
@@ -612,7 +618,9 @@ QPointF QDeclarativePath::backwardsPointAt(const QPainterPath &path, const qreal
Q_ASSERT(!(currElement < firstElement));
Q_UNUSED(firstElement);
currBez = nextBezier(path, &currElement, &bezLength, true /*reverse*/);
- currLength = prevLength;
+ //special case for first element is to avoid floating point math
+ //causing an epc that never hits 0.
+ currLength = (currElement == firstElement) ? bezLength : prevLength;
prevLength = currLength - bezLength;
epc = prevLength / pathLength;
}