diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-10-06 21:13:18 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-10-09 15:47:39 +0200 |
commit | 26bbd784d67d151eee531e5ff57977a5353549f5 (patch) | |
tree | d8fc6acf27cbc6cde96a36a0aa8b8a77917feb73 /src/quick/util/qquickanimatorjob_p.h | |
parent | 5a0eb9bebc002cc6e8de2dad6247c2b419571ade (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/qquickanimatorjob_p.h')
-rw-r--r-- | src/quick/util/qquickanimatorjob_p.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index f91410950c..4bdcd6917d 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -122,7 +122,7 @@ public: QEasingCurve easingCurve() const { return m_easing; } void setEasingCurve(const QEasingCurve &curve) { m_easing = curve; } - void targetWasDeleted(); + virtual void targetWasDeleted(); virtual void initialize(QQuickAnimatorController *controller); virtual void writeBack() = 0; virtual void nodeWasDestroyed() = 0; @@ -204,6 +204,7 @@ protected: QQuickTransformAnimatorJob(); void initialize(QQuickAnimatorController *controller); void nodeWasDestroyed(); + void targetWasDeleted() Q_DECL_OVERRIDE; Helper *m_helper; }; |