From 70fb72ca17b5176bb551a7ae9f2129b48496c635 Mon Sep 17 00:00:00 2001
From: Martin Jones <martin.jones@nokia.com>
Date: Thu, 24 Mar 2011 13:36:57 +1000
Subject: Fix memory leak.

Change-Id: I919935399ee1b0e505c85781d481d17345df25c9
Task-number: QT-4330
Reviewed-by: Michael Brasser
---
 src/declarative/util/qdeclarativeanimation.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index ac9c3c0..67461b0 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -2765,6 +2765,8 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
             d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped);
             d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped);
         }
+        if (!d->via)
+            delete viaData;
     } else {
         delete data;
         delete viaData;
-- 
cgit v0.12


From 903fdabf3eb808a96e2a869049c2095cde09d2be Mon Sep 17 00:00:00 2001
From: Alan Alpert <alan.alpert@nokia.com>
Date: Fri, 25 Mar 2011 09:37:46 +1000
Subject: Fix QUnifiedTimer bug

Pause animations (like Timer) could trigger a jump to the next tick,
which meant that other pause animations would have missed the interval
skipped by the pause.

Change-Id: Idebe4cbe70b2a1536d684288fc1c5d65e4c5df84
Cherry-pick-of: 0f5feed7dc260eabe1c2784a168e0b2fcc85e1d8
Task-number: QTBUG-18126
Reviewed-by: Leo Cunha
Reviewed-by: Michael Brasser
---
 src/corelib/animation/qabstractanimation.cpp | 8 +++++++-
 src/corelib/animation/qabstractanimation_p.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 5e6110f..a9bb129 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -167,7 +167,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
 
 QUnifiedTimer::QUnifiedTimer() :
     QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
-    currentAnimationIdx(0), consistentTiming(false), slowMode(false),
+    insideTick(false), currentAnimationIdx(0), consistentTiming(false), slowMode(false),
     slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
 {
     time.invalidate();
@@ -205,6 +205,10 @@ void QUnifiedTimer::ensureTimerUpdate()
 
 void QUnifiedTimer::updateAnimationsTime()
 {
+    //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
+    if(insideTick)
+        return;
+
     qint64 totalElapsed = time.elapsed();
     // ignore consistentTiming in case the pause timer is active
     int delta = (consistentTiming && !isPauseTimerActive) ?
@@ -222,12 +226,14 @@ void QUnifiedTimer::updateAnimationsTime()
     //it might happen in some cases that the time doesn't change because events are delayed
     //when the CPU load is high
     if (delta) {
+        insideTick = true;
         for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
             QAbstractAnimation *animation = animations.at(currentAnimationIdx);
             int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
                           + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
             animation->setCurrentTime(elapsed);
         }
+        insideTick = false;
         currentAnimationIdx = 0;
     }
 }
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index c0488c8..aeee1f2 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -175,6 +175,7 @@ private:
     qint64 lastTick;
     int timingInterval;
     int currentAnimationIdx;
+    bool insideTick;
     bool consistentTiming;
     bool slowMode;
 
-- 
cgit v0.12