aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/quick/items/qquickanimatedimage.cpp24
-rw-r--r--src/quick/items/qquickanimatedimage_p_p.h3
2 files changed, 17 insertions, 10 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()
diff --git a/src/quick/items/qquickanimatedimage_p_p.h b/src/quick/items/qquickanimatedimage_p_p.h
index bb921fda4a..ed1bf368c8 100644
--- a/src/quick/items/qquickanimatedimage_p_p.h
+++ b/src/quick/items/qquickanimatedimage_p_p.h
@@ -60,7 +60,7 @@ class QQuickAnimatedImagePrivate : public QQuickImagePrivate
public:
QQuickAnimatedImagePrivate()
- : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0), oldPlaying(false)
+ : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0), oldPlaying(false), currentSourceSize(0, 0)
{
}
@@ -74,6 +74,7 @@ public:
int redirectCount;
bool oldPlaying;
QMap<int, QQuickPixmap *> frameMap;
+ QSize currentSourceSize;
};
QT_END_NAMESPACE