aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickanimatedimage.cpp
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig@kdab.com>2016-04-27 08:12:12 +0200
committerTobias Koenig <tobias.koenig@kdab.com>2016-05-02 06:49:54 +0000
commitbe031102c226ab9bccc1e73018af25082240bcc3 (patch)
tree1d7a271174527b9dbb48e2bda5d72510f45e0221 /src/quick/items/qquickanimatedimage.cpp
parent1650377af7dfb01a0641d4e21bf1ba33e6a7320f (diff)
AnimatedImage: Fix value of sourceSize property
Cache the source size of the internal QMovie object during the change of the 'source' property to ensure that always a valid source size is returned without emitting more sourceSizeChanged() signals than necessary. Change-Id: I637b80efb133197b7345b09fcf8a7bb80c5643c9 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/quick/items/qquickanimatedimage.cpp')
-rw-r--r--src/quick/items/qquickanimatedimage.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 49fef12467..11dad5b001 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -294,8 +294,9 @@ void QQuickAnimatedImage::load()
d->status = Null;
emit statusChanged(d->status);
- if (sourceSize() != d->oldSourceSize) {
- d->oldSourceSize = sourceSize();
+ d->currentSourceSize = QSize(0, 0);
+ if (d->currentSourceSize != d->oldSourceSize) {
+ d->oldSourceSize = d->currentSourceSize;
emit sourceSizeChanged();
}
if (isPlaying() != d->oldPlaying)
@@ -366,8 +367,9 @@ void QQuickAnimatedImage::movieRequestFinished()
d->status = Error;
emit statusChanged(d->status);
- if (sourceSize() != d->oldSourceSize) {
- d->oldSourceSize = sourceSize();
+ d->currentSourceSize = QSize(0, 0);
+ if (d->currentSourceSize != d->oldSourceSize) {
+ d->oldSourceSize = d->currentSourceSize;
emit sourceSizeChanged();
}
if (isPlaying() != d->oldPlaying)
@@ -404,8 +406,14 @@ void QQuickAnimatedImage::movieRequestFinished()
if (isPlaying() != d->oldPlaying)
emit playingChanged();
- if (sourceSize() != d->oldSourceSize) {
- d->oldSourceSize = sourceSize();
+
+ if (d->_movie)
+ d->currentSourceSize = d->_movie->currentPixmap().size();
+ else
+ d->currentSourceSize = QSize(0, 0);
+
+ if (d->currentSourceSize != d->oldSourceSize) {
+ d->oldSourceSize = d->currentSourceSize;
emit sourceSizeChanged();
}
}
@@ -458,9 +466,7 @@ void QQuickAnimatedImage::onCacheChanged()
QSize QQuickAnimatedImage::sourceSize()
{
Q_D(QQuickAnimatedImage);
- if (!d->_movie)
- return QSize(0, 0);
- return QSize(d->_movie->currentPixmap().size());
+ return d->currentSourceSize;
}
void QQuickAnimatedImage::componentComplete()