diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-30 23:17:36 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-30 23:17:36 (GMT) |
commit | 95a6da90926d1887fc04a95df8d887b4872ccae8 (patch) | |
tree | a310fcdf9c6a273fe6dee3978ef28355c3868955 /src/declarative | |
parent | a6f4b0bbcf7f75bb5e615da1911c26bea2c95be3 (diff) | |
download | Qt-95a6da90926d1887fc04a95df8d887b4872ccae8.zip Qt-95a6da90926d1887fc04a95df8d887b4872ccae8.tar.gz Qt-95a6da90926d1887fc04a95df8d887b4872ccae8.tar.bz2 |
Don't access uninitialized value.
Viewport can move before any mouse press.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeflickable.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 65bc233..a40546f 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -971,20 +971,19 @@ void QDeclarativeFlickable::viewportMoved() { Q_D(QDeclarativeFlickable); - int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime); - if (!elapsed) - return; - qreal prevY = d->lastFlickablePosition.x(); qreal prevX = d->lastFlickablePosition.y(); d->velocityTimeline.clear(); if (d->pressed) { - qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed; - qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed; - d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing); + int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime); + if (elapsed > 0) { + qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed; + qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed; + d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing); + } } else { if (d->timeline.time() > d->vTime) { qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime); |