Fix memory leaks in QQuickParentAnimation
authorCharles Yin <charles.yin@nokia.com>
Mon, 28 May 2012 23:50:08 +0000 (09:50 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 29 May 2012 03:57:48 +0000 (05:57 +0200)
Change-Id: I7b386b3b5f974e068c7ca00d3d9ea92a62fc70d9
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/quick/items/qquickitemanimation.cpp

index 5409203..e79b9c3 100644 (file)
@@ -371,13 +371,13 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
         }
     }
 
-    QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
-    QActionAnimation *viaAction = d->via ? new QActionAnimation : 0;
-    QActionAnimation *targetAction = new QActionAnimation;
-    //we'll assume the common case by far is to have children, and always create ag
-    QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
-
     if (data->actions.count()) {
+        QSequentialAnimationGroupJob *topLevelGroup = new QSequentialAnimationGroupJob;
+        QActionAnimation *viaAction = d->via ? new QActionAnimation : 0;
+        QActionAnimation *targetAction = new QActionAnimation;
+        //we'll assume the common case by far is to have children, and always create ag
+        QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
+
         if (d->via)
             viaAction->setAnimAction(viaData);
         targetAction->setAnimAction(data);
@@ -405,12 +405,12 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
             topLevelGroup->appendAnimation(ag);
             topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
         }
+        return initInstance(topLevelGroup);
     } else {
         delete data;
         delete viaData;
     }
-
-    return initInstance(topLevelGroup);
+    return 0;
 }
 
 /*!