aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickanimatorcontroller.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2014-10-06 21:13:18 +0200
committerGunnar Sletta <gunnar@sletta.org>2014-10-09 15:47:39 +0200
commit26bbd784d67d151eee531e5ff57977a5353549f5 (patch)
treed8fc6acf27cbc6cde96a36a0aa8b8a77917feb73 /src/quick/util/qquickanimatorcontroller.cpp
parent5a0eb9bebc002cc6e8de2dad6247c2b419571ade (diff)
Fix memory leak and crash with transform animators.
Every time initialize() was called, we would increment the ref on an item. However, initialize is called every time the job is started, so the ref would increase and only decrease once, leading to a leaked helper. Change it to only increment the first time. A different problem was that when an item was destroyed, we could run the risk of the QQuickTransformAnimatorJob destructor being called with the helper's item being null. This would lead to the helper not being removed from the cache and a dangling helper would remain in the transforms cache. Now change it so that when a target is destroyed, we explicitly destroy the helper as well (as no animation can happen then anyway) and reset all pointers in the job. Change-Id: I1ce76db134bbc1871d32f1224ba5b68a4a4eeafa Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/util/qquickanimatorcontroller.cpp')
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index 42b8840bf4..e009de205c 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -184,8 +184,6 @@ void QQuickAnimatorController::beforeNodeSync()
m_nodesAreInvalid = false;
}
-
-
foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) {
if (!job->target())
continue;
@@ -197,9 +195,9 @@ void QQuickAnimatorController::beforeNodeSync()
}
}
foreach (QQuickItem *wiped, m_deletedSinceLastFrame) {
- QQuickTransformAnimatorJob::Helper *helper = m_transforms.value(wiped);
- if (helper)
- helper->item = 0;
+ QQuickTransformAnimatorJob::Helper *helper = m_transforms.take(wiped);
+ // Helper will now already have been reset in all animators referencing it.
+ delete helper;
}
m_deletedSinceLastFrame.clear();