diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-02-27 15:17:35 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-18 11:54:39 +0000 |
commit | 9538cd7fbe43b1479f23a37bc8f19012981257a6 (patch) | |
tree | 4c89236683b39870176d60106060fad4b0d389b8 /src/quick/util | |
parent | fc8d503321faffa1638a8bfa161d0784e2e1325b (diff) |
QQuickAnimatorProxyJob: make sure to stop when detached from a window
The previous attempt to fix this (05a88ef) had to be reverted (7fe0d1a)
because Q_ASSERT(m_controller) in updateCurrentTime() failed in QQC1
auto tests. It seems that m_controller can be null when m_internalState
is still State_Starting.
Task-number: QTBUG-59034
Task-number: QTBUG-59953
Change-Id: I07ceec8fe4e66ba0571092b4385d8140035a4b33
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Reviewed-by: Aleix Pol
Reviewed-by: Gunnar Sletta <gunnar@crimson.no>
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickanimatorjob.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 89007cff1f..caf702bde5 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -140,6 +140,14 @@ QObject *QQuickAnimatorProxyJob::findAnimationContext(QQuickAbstractAnimation *a void QQuickAnimatorProxyJob::updateCurrentTime(int) { + if (m_internalState != State_Running) + return; + + // A proxy which is being ticked should be associated with a window, (see + // setWindow() below). If we get here when there is no more controller we + // have a problem. + Q_ASSERT(m_controller); + // We do a simple check here to see if the animator has run and stopped on // the render thread. isPendingStart() will perform a check against jobs // that have been scheduled for start, but that will not yet have entered @@ -150,8 +158,7 @@ void QQuickAnimatorProxyJob::updateCurrentTime(int) // we might get the wrong value for this update, but then we'll simply // pick it up on the next iterationm when the job is stopped and render // thread is no longer using it. - if (m_internalState == State_Running - && !m_controller->isPendingStart(m_job) + if (!m_controller->isPendingStart(m_job) && !m_job->isRunning()) { stop(); } @@ -167,9 +174,9 @@ void QQuickAnimatorProxyJob::updateState(QAbstractAnimationJob::State newState, } } else if (newState == Stopped) { - syncBackCurrentValues(); m_internalState = State_Stopped; if (m_controller) { + syncBackCurrentValues(); m_controller->cancel(m_job); } } @@ -193,6 +200,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window) if (m_job && m_controller) m_controller->cancel(m_job); m_controller = nullptr; + stop(); } else if (!m_controller && m_job) { m_controller = QQuickWindowPrivate::get(window)->animationController; |