diff options
| author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-17 16:21:19 +0100 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-19 19:05:22 +0100 |
| commit | 0c066168bbbd230abe875727b2000d6828b03f23 (patch) | |
| tree | 2a927708edc62e2022d0093dd264206761d29066 /src | |
| parent | 02c6e7bc3aca42a188b772aa9794b919e60017e7 (diff) | |
QQuickFlickable: Avoid casting and rounding
The reportedVelocitySmoothing variable is never changed, and only used
as a parameter that is an int. So declare it as a const int instead of
qreal, and pass a floating-type zero for the destination parameter that
is of type qreal.
Fixes static analzyer warning 8e9457b62b3d1ff06f55ca46ba0e70ef
Change-Id: Ie9226a107dfaaf937d126833f8ba2786ac3d1e6b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/items/qquickflickable.cpp | 10 | ||||
| -rw-r--r-- | src/quick/items/qquickflickable_p_p.h | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 194016f207..7db1d1f5b5 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -77,6 +77,10 @@ static const int FlickThreshold = 15; // will ensure the Flickable retains the grab on consecutive flicks. static const int RetainGrabVelocity = 100; +// ReportedVelocitySmoothing determines how reported velocity is +// smoothed to avoid erratic output. +static const int ReportedVelocitySmoothing = 100; + // Currently std::round can't be used on Android when using ndk g++, so // use C version instead. We could just define two versions of Round, one // for float and one for double, but then only one of them would be used @@ -269,7 +273,7 @@ QQuickFlickablePrivate::QQuickFlickablePrivate() , lastPosTime(-1) , lastPressTime(0) , deceleration(QML_FLICK_DEFAULTDECELERATION) - , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) + , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY) , delayedPressEvent(nullptr), pressDelay(0), fixupDuration(400) , flickBoost(1.0), fixupMode(Normal), vTime(0), visibleArea(nullptr) , flickableDirection(QQuickFlickable::AutoFlickDirection) @@ -1941,8 +1945,8 @@ void QQuickFlickablePrivate::viewportAxisMoved(AxisData &data, qreal minExtent, if (calcVelocity) velocityTimeline.set(data.smoothVelocity, velocity); else - velocityTimeline.move(data.smoothVelocity, velocity, reportedVelocitySmoothing); - velocityTimeline.move(data.smoothVelocity, 0, reportedVelocitySmoothing); + velocityTimeline.move(data.smoothVelocity, velocity, ReportedVelocitySmoothing); + velocityTimeline.move(data.smoothVelocity, 0, ReportedVelocitySmoothing); qCDebug(lcVel) << "touchpad scroll phase: velocity" << velocity; } } diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index 5f46c881b5..5e098dfdda 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -234,7 +234,6 @@ public: QVector2D accumulatedWheelPixelDelta; qreal deceleration; qreal maxVelocity; - qreal reportedVelocitySmoothing; QPointerEvent *delayedPressEvent; QBasicTimer delayedPressTimer; int pressDelay; |
