From 2149e9e617f72324bc9297ade3dc1884e15d75c1 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Tue, 3 Apr 2012 16:52:29 +1000 Subject: [PATCH] Rewrite QAnimationGroupJob::clear() method Before removing and deleting children, set the m_group to 0 to avoid potential cycling deletions when this method is called from QAnimationGroupJob::~QAnimationGroupJob(). Change-Id: Idb6920be71fc9e033e5a76b724c9550018995035 Reviewed-by: Michael Brasser --- src/qml/animations/qanimationgroupjob.cpp | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qml/animations/qanimationgroupjob.cpp b/src/qml/animations/qanimationgroupjob.cpp index 83b2192..59bceaa 100644 --- a/src/qml/animations/qanimationgroupjob.cpp +++ b/src/qml/animations/qanimationgroupjob.cpp @@ -51,8 +51,7 @@ QAnimationGroupJob::QAnimationGroupJob() QAnimationGroupJob::~QAnimationGroupJob() { - while (firstChild() != 0) - delete firstChild(); + clear(); } void QAnimationGroupJob::topLevelAnimationLoopChanged() @@ -123,9 +122,16 @@ void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation) void QAnimationGroupJob::clear() { - //### should this remove and delete, or just remove? - while (firstChild() != 0) - delete firstChild(); //removeAnimation(firstChild()); + QAbstractAnimationJob *child = firstChild(); + QAbstractAnimationJob *nextSibling = 0; + while (child != 0) { + child->m_group = 0; + nextSibling = child->nextSibling(); + delete child; + child = nextSibling; + } + m_firstChild = 0; + m_lastChild = 0; } void QAnimationGroupJob::resetUncontrolledAnimationsFinishTime() -- 1.7.2.5