summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2018-05-31 15:06:25 +0200
committerAndy Nichols <andy.nichols@qt.io>2018-06-01 07:50:34 +0000
commitd04a3681aad20c486c289ee968656cbe0e00bfaf (patch)
tree0dc709d292cc01774b20c1d797aa6ef5f2f58463
parentc42da985512cbbf013f6a5f9823f83a2a9836c53 (diff)
Fix an issue where looping animations stopped themselves
Now we use a fuzzy compare to see if we are within 0.1 ms of the end of a slide, as we don't receive another position update if we are already so close to the end. Change-Id: Ie2c021be00d5a7bdac5fa632c39969bb45c0a2d5 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--src/runtime/q3dsslideplayer.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp
index 2db55f3..0388ab1 100644
--- a/src/runtime/q3dsslideplayer.cpp
+++ b/src/runtime/q3dsslideplayer.cpp
@@ -728,9 +728,17 @@ void Q3DSSlidePlayer::sendPositionChanged(Q3DSSlide *slide, float pos)
if (!qFuzzyCompare(oldPosition, pos))
Q_EMIT positionChanged(pos);
- const bool onEOS = (m_data.state == PlayerState::Playing && m_data.pendingState == PlayerState::Playing)
- && ((m_data.position == 0.0f && m_data.playbackRate < 0.0f)
- || (m_data.position == duration() && m_data.playbackRate > 0.0f));
+ // Check if we are close enough to the end of playback that we
+ // are unlikely to get another position change
+ float timeLeft = 0.0f;
+ if (m_data.playbackRate < 0.0f)
+ timeLeft = m_data.position;
+ else
+ timeLeft = qMax(0.0f, duration() - m_data.position);
+
+ const bool onEOS = m_data.state == PlayerState::Playing
+ && m_data.pendingState == PlayerState::Playing
+ && timeLeft < 0.1f;
if (onEOS)
onSlideFinished(slide);