diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-01-06 06:57:06 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-01-06 06:57:06 (GMT) |
commit | 05b9137fe1974aa123ce6d9c16b733e1f77d8269 (patch) | |
tree | 6965ebdba00a655ee879bc969986cd24753c6823 /src/declarative/graphicsitems | |
parent | 1ba3e41f09ea719249286fede5d3fe96621ccb61 (diff) | |
download | Qt-05b9137fe1974aa123ce6d9c16b733e1f77d8269.zip Qt-05b9137fe1974aa123ce6d9c16b733e1f77d8269.tar.gz Qt-05b9137fe1974aa123ce6d9c16b733e1f77d8269.tar.bz2 |
PathView crashed when the path is provided with undefined values.
Task-number: QTBUG-16356
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepath.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index 966c51b..e63a2c3 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -46,6 +46,8 @@ #include <QTime> #include <private/qbezier_p.h> +#include <QtCore/qmath.h> +#include <QtCore/qnumeric.h> QT_BEGIN_NAMESPACE @@ -367,9 +369,11 @@ void QDeclarativePath::createPointCache() const { Q_D(const QDeclarativePath); qreal pathLength = d->_path.length(); + if (pathLength <= 0 || qIsNaN(pathLength)) + return; // more points means less jitter between items as they move along the // path, but takes longer to generate - const int points = int(pathLength*5); + const int points = qCeil(pathLength*5); const int lastElement = d->_path.elementCount() - 1; d->_pointCache.resize(points+1); @@ -418,6 +422,8 @@ QPointF QDeclarativePath::pointAt(qreal p) const Q_D(const QDeclarativePath); if (d->_pointCache.isEmpty()) { createPointCache(); + if (d->_pointCache.isEmpty()) + return QPointF(); } int idx = qRound(p*d->_pointCache.size()); if (idx >= d->_pointCache.size()) |