diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-05-15 21:01:06 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-19 11:15:08 +0200 |
commit | 851ae1a77dc207ec11b8ed3f0786bfe1c1905e4c (patch) | |
tree | 6576f581a94851366e4481ea6994b610636f5fe0 /src/quick/util/qquickanimatorjob.cpp | |
parent | 8f6254a88e4c634203df779aa385d9955e91b56f (diff) |
Fix crash with running animators on re-shown windows.
The non-threaded render loops would clean up the nodes for a window
when it was hidden, but the animators kept running and had a reference
to the deleted nodes. This was not a problem for the threaded render
loop as it would wipe the animator controller as well which would
clean the jobs.
Fix it by triggering a reset of all nodes in the animators when the
window is told to clean up. If an animator is ticked when it doesn't
have a node, it will simply do nothing. When the window is made visible
again, we call initialize on all animators to find the new node.
Task-number: QTBUG-37995
Change-Id: Ie5609d95db29f4b2b30ca5bf641dce901e528389
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/util/qquickanimatorjob.cpp')
-rw-r--r-- | src/quick/util/qquickanimatorjob.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 3bc4cef5b9..0bf95a49b4 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -281,6 +281,12 @@ void QQuickTransformAnimatorJob::initialize(QQuickAnimatorController *controller } } +void QQuickTransformAnimatorJob::nodeWasDestroyed() +{ + if (m_helper) + m_helper->node = 0; +} + void QQuickTransformAnimatorJob::Helper::sync() { const quint32 mask = QQuickItemPrivate::Position @@ -326,7 +332,7 @@ void QQuickTransformAnimatorJob::Helper::sync() void QQuickTransformAnimatorJob::Helper::apply() { - if (!wasChanged) + if (!wasChanged || !node) return; QMatrix4x4 m; @@ -412,6 +418,11 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller) } } +void QQuickOpacityAnimatorJob::nodeWasDestroyed() +{ + m_opacityNode = 0; +} + void QQuickOpacityAnimatorJob::writeBack() { if (m_target) @@ -420,7 +431,7 @@ void QQuickOpacityAnimatorJob::writeBack() void QQuickOpacityAnimatorJob::updateCurrentTime(int time) { - if (!m_controller) + if (!m_controller || !m_opacityNode) return; Q_ASSERT(m_controller->m_window->openglContext()->thread() == QThread::currentThread()); @@ -504,13 +515,18 @@ void QQuickUniformAnimatorJob::setTarget(QQuickItem *target) m_target = target; } +void QQuickUniformAnimatorJob::nodeWasDestroyed() +{ + m_node = 0; + m_uniformIndex = -1; + m_uniformType = -1; +} + void QQuickUniformAnimatorJob::afterNodeSync() { m_node = static_cast<QQuickShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode); - if (m_node) { - m_uniformIndex = -1; - m_uniformType = -1; + if (m_node && m_uniformIndex == -1 && m_uniformType == -1) { QQuickShaderEffectMaterial *material = static_cast<QQuickShaderEffectMaterial *>(m_node->material()); bool found = false; |