Port change 67ed1849 from Qt 4.7
authorMartin Jones <martin.jones@nokia.com>
Mon, 12 Sep 2011 02:40:20 +0000 (12:40 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Sep 2011 05:49:16 +0000 (07:49 +0200)
Flickable could flick in wrong direction if given too few touch samples

If we got <= QML_FLICK_DISCARDSAMPLES the previous velocity was not
cleared, so the view would continue flicking with the previous
velocity, and therefore the previous direction.

Task-number: QT-4903

Change-Id: Ie4c2a3829026c0bf7d94cf5b60c0b7ff9833f725
Reviewed-on: http://codereview.qt-project.org/4618
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/declarative/items/qsgflickable.cpp

index 962eb96..359d150 100644 (file)
@@ -235,8 +235,8 @@ void QSGFlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity
 
 void QSGFlickablePrivate::AxisData::updateVelocity()
 {
+    velocity = 0;
     if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) {
-        velocity = 0;
         int count = velocityBuffer.count()-QML_FLICK_DISCARDSAMPLES;
         for (int i = 0; i < count; ++i) {
             qreal v = velocityBuffer.at(i);