aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-04-23 17:05:26 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-19 00:45:57 +0200
commitc2df9ce7b0cb6ac9a9117578a167d54a708c64b3 (patch)
tree7bacede462f1ca21886e9a36cbcf3bc4fa538cfc /src/quick/items
parentd62abf12a4d6e303d585850724f8ddc0ab448a75 (diff)
Resume AnimatedSprite playback when visibility changes
Amends f5e2783 that was made in 5.6 to avoid updating the AnimatedSprite when not visible. The problem is, if the sprite was running, the expectation is that becoming visible again resumes the playback. It can be argued what the correct behavior is: do we expect the playback to resume from the point when the sprite went invisible, or should it take the time spent as invisible into account? This patch only corrects the immediate problem and provides the former, i.e. playback will resume from the point it had when becoming invisible. The AnimatedSprite scene in the imageelements example is improved to be able to test this. It can also exercise all the start/pause/resume/advance functions now. Fixes: QTBUG-63942 Change-Id: Ieb6d046168a2132659848a36ee0b694c580159b1 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit af521a8df6caec41f626a4b3319601c20adff711) Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp8
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index b285fe56ed..f239f24367 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -502,6 +502,14 @@ void QQuickAnimatedSprite::maybeUpdate()
update();
}
+void QQuickAnimatedSprite::itemChange(ItemChange change, const ItemChangeData &value)
+{
+ Q_D(QQuickAnimatedSprite);
+ if (change == ItemVisibleHasChanged && d->m_running && !d->m_paused)
+ maybeUpdate();
+ QQuickItem::itemChange(change, value);
+}
+
/*!
\qmlmethod int QtQuick::AnimatedSprite::pause()
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index 546598a409..49fb6ddeea 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -183,6 +183,8 @@ protected Q_SLOTS:
protected:
void componentComplete() override;
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
+ void itemChange(ItemChange, const ItemChangeData &) override;
+
private:
void maybeUpdate();
bool isCurrentFrameChangedConnected();