aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-12-07 09:04:00 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-12-07 14:54:18 +0000
commitf9f99c43fbea600f61d065b30a5453e95dfa6ade (patch)
tree038fc2abe32b84a4b8053fd37f0357c03d3f3e72 /src
parent94e9fab2d81d076fd59a6a5a4d4ef093f37e05f9 (diff)
QQuickAnimatorJob: store the target with a QPointer
This avoids ending up with invalid pointers when under some circumstances the target (which is not owned by the QQuickAnimatorJob) is destroyed between the time the QQuickAnimatorJob is created and the time it is initialized. This is the case when the target of an Animator is the item loaded by a Loader and that the animator is started just before setting the Loader to inactive. Also added an auto test for that special case. Task-number: QTBUG-49634 Change-Id: Iab9bfe76d13755ba735432c6f97bde175d308814 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp5
-rw-r--r--src/quick/util/qquickanimatorjob_p.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index cfb6037d14..74930fb373 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -140,6 +140,11 @@ static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorC
{
if (job->isRenderThreadJob()) {
QQuickAnimatorJob *j = static_cast<QQuickAnimatorJob *>(job);
+ // Note: since a QQuickAnimatorJob::m_target is a QPointer,
+ // if m_target is destroyed between the time it was set
+ // as the target of the animator job and before this step,
+ // (e.g a Loader being set inactive just after starting the animator)
+ // we are sure it will be NULL and won't be dangling around
if (!j->target()) {
return;
} else if (c->m_deletedSinceLastFrame.contains(j->target())) {
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index 82c9da1d2e..35057d6278 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -152,7 +152,7 @@ protected:
QQuickAnimatorJob();
void debugAnimation(QDebug d) const Q_DECL_OVERRIDE;
- QQuickItem *m_target;
+ QPointer<QQuickItem> m_target;
QQuickAnimatorController *m_controller;
qreal m_from;