From cb48b1bd67e094446cf73d8a0940d25dc8334708 Mon Sep 17 00:00:00 2001
From: Warwick Allison <warwick.allison@nokia.com>
Date: Wed, 4 Nov 2009 18:10:08 +1000
Subject: Remove property-order sensitivity. Fixes autotest.

---
 .../extra/qmlgraphicsanimatedimageitem.cpp            | 19 +++++++++++++++----
 .../extra/qmlgraphicsanimatedimageitem_p.h            |  1 +
 .../extra/qmlgraphicsanimatedimageitem_p_p.h          |  3 ++-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp b/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
index f3c2058..ba09279 100644
--- a/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
+++ b/src/declarative/extra/qmlgraphicsanimatedimageitem.cpp
@@ -158,15 +158,17 @@ int QmlGraphicsAnimatedImageItem::currentFrame() const
 {
     Q_D(const QmlGraphicsAnimatedImageItem);
     if (!d->_movie)
-        return -1;
+        return d->preset_currentframe;
     return d->_movie->currentFrameNumber();
 }
 
 void QmlGraphicsAnimatedImageItem::setCurrentFrame(int frame)
 {
     Q_D(QmlGraphicsAnimatedImageItem);
-    if (!d->_movie)
+    if (!d->_movie) {
+        d->preset_currentframe = frame;
         return;
+    }
     d->_movie->jumpToFrame(frame);
 }
 
@@ -264,8 +266,10 @@ void QmlGraphicsAnimatedImageItem::movieRequestFinished()
     d->_movie->setCacheMode(QMovie::CacheAll);
     if(d->playing)
         d->_movie->start();
-    else
-        d->_movie->jumpToFrame(0);
+    else {
+        d->_movie->jumpToFrame(d->preset_currentframe);
+        d->preset_currentframe = 0;
+    }
     if(d->paused)
         d->_movie->setPaused(true);
     d->setPixmap(d->_movie->currentPixmap());
@@ -291,4 +295,11 @@ void QmlGraphicsAnimatedImageItem::playingStatusChanged()
     }
 }
 
+void QmlGraphicsAnimatedImageItem::componentComplete()
+{
+    Q_D(QmlGraphicsAnimatedImageItem);
+    setCurrentFrame(d->preset_currentframe);
+    d->preset_currentframe = 0;
+}
+
 QT_END_NAMESPACE
diff --git a/src/declarative/extra/qmlgraphicsanimatedimageitem_p.h b/src/declarative/extra/qmlgraphicsanimatedimageitem_p.h
index 097aecd..b581ea3 100644
--- a/src/declarative/extra/qmlgraphicsanimatedimageitem_p.h
+++ b/src/declarative/extra/qmlgraphicsanimatedimageitem_p.h
@@ -91,6 +91,7 @@ private Q_SLOTS:
 
 protected:
     QmlGraphicsAnimatedImageItem(QmlGraphicsAnimatedImageItemPrivate &dd, QmlGraphicsItem *parent);
+    void componentComplete();
 
 private:
     Q_DISABLE_COPY(QmlGraphicsAnimatedImageItem)
diff --git a/src/declarative/extra/qmlgraphicsanimatedimageitem_p_p.h b/src/declarative/extra/qmlgraphicsanimatedimageitem_p_p.h
index 0b12d2f..2256b9b 100644
--- a/src/declarative/extra/qmlgraphicsanimatedimageitem_p_p.h
+++ b/src/declarative/extra/qmlgraphicsanimatedimageitem_p_p.h
@@ -66,12 +66,13 @@ class QmlGraphicsAnimatedImageItemPrivate : public QmlGraphicsImagePrivate
 
 public:
     QmlGraphicsAnimatedImageItemPrivate()
-      : playing(true), paused(false), _movie(0), reply(0)
+      : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0)
     {
     }
 
     bool playing;
     bool paused;
+    int preset_currentframe;
     QMovie *_movie;
     QNetworkReply *reply;
 };
-- 
cgit v0.12