aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2023-12-13 14:36:59 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-12-18 01:41:24 +0000
commite1b190c8d644c1f5489f96fa8566f85470078013 (patch)
treefd27bab07cbc26b2a24949243d767d706336fe61 /src
parent1c7ada23e46330c639378856a7f8bf7d4ebc48d9 (diff)
Make sure updateCurrentTime() is done on with a valid ShaderEffect
The target might change several times, or worse have been destroyed, while updates are still queued, and since the effect pointer isn't updated until the postSync() call, the effect pointer can get out of sync leaving it pointing to the wrong object, or a destroyed one. To avoid operating on an destroyed or old handle, check if the current effect is valid and matches the target before applying the uniform values in updateCurrentTime(). Pick-to: 6.5 6.2 Fixes: QTBUG-119363 Change-Id: I5172ccf9405c1d789f197a0cf8cec4c749bd7d28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 60e49dfbe3cf8276aabfcf7bf00dc532dea78baf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 9c1065ce400b1cf1dd5599c1e9efbf12c61516fa)
Diffstat (limited to 'src')
-rw-r--r--src/quick/util/qquickanimatorjob.cpp4
-rw-r--r--src/quick/util/qquickanimatorjob_p.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index 1ac87b6b74..83d5181c34 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -592,7 +592,7 @@ void QQuickUniformAnimatorJob::setTarget(QQuickItem *target)
void QQuickUniformAnimatorJob::updateCurrentTime(int time)
{
- if (!m_effect)
+ if (!m_effect || m_target != m_effect)
return;
m_value = m_from + (m_to - m_from) * progress(time);
@@ -617,7 +617,7 @@ void QQuickUniformAnimatorJob::postSync()
void QQuickUniformAnimatorJob::invalidate()
{
- m_effect = nullptr;
+
}
#endif
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index fef29ac385..9a1ad53e7a 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -280,7 +280,7 @@ public:
private:
QByteArray m_uniform;
- QQuickShaderEffect *m_effect = nullptr;
+ QPointer<QQuickShaderEffect> m_effect;
};
#endif