diff options
author | Charles Yin <charles.yin@nokia.com> | 2012-03-22 14:07:28 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-23 05:19:35 +0100 |
commit | b63ce68f316c91b0a3107d3d20e160628f5cefef (patch) | |
tree | 89aaa6345d595097a4975e4455a7dd65e02ed1be /src | |
parent | c913351c9d6e3181cdddcc851e9d80cd7689fe93 (diff) |
Fix crash issue for path animation and path interpulator
When set progress value out of [0,1], path animation and
path interpulator should make sure the value be modified
in the valid value range, otherwise the QQuickPath::backwardsPointAt()
will crash.
Task-number: QTBUG-24308
Change-Id: Icd6e9165c9f844ddb8ec84c229eac4db5246a749
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitemanimation.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickpath.cpp | 2 | ||||
-rw-r--r-- | src/quick/util/qquickpathinterpolator.cpp | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp index a1c398eeb6..3e84eb6115 100644 --- a/src/quick/items/qquickitemanimation.cpp +++ b/src/quick/items/qquickitemanimation.cpp @@ -927,6 +927,8 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio void QQuickPathAnimationUpdater::setValue(qreal v) { + v = qMin(qMax(v, (qreal)0.0), (qreal)1.0);; + if (interruptStart.isValid()) { if (reverse) v = 1 - v; diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index adf4242cdc..8dadab620a 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -527,6 +527,8 @@ QPointF QQuickPath::sequentialPointAt(qreal p, qreal *angle) const QPointF QQuickPath::sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle) { + Q_ASSERT(p >= 0.0 && p <= 1.0); + if (!prevBez.isValid) return p > .5 ? backwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle) : forwardsPointAt(path, pathLength, attributePoints, prevBez, p, angle); diff --git a/src/quick/util/qquickpathinterpolator.cpp b/src/quick/util/qquickpathinterpolator.cpp index 2b5fb62872..ee1424b70f 100644 --- a/src/quick/util/qquickpathinterpolator.cpp +++ b/src/quick/util/qquickpathinterpolator.cpp @@ -102,6 +102,8 @@ qreal QQuickPathInterpolator::progress() const void QQuickPathInterpolator::setProgress(qreal progress) { + progress = qMin(qMax(progress, (qreal)0.0), (qreal)1.0); + if (progress == _progress) return; _progress = progress; |