summaryrefslogtreecommitdiffstats
path: root/src/animation/backend/handler.cpp
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2017-11-14 14:23:56 +0100
committerAndy Nichols <andy.nichols@qt.io>2017-11-15 10:13:52 +0000
commit9b6f95d64374338d00bc619acf30584c4ec78c4e (patch)
tree4c82e5a99defb4a10a21aac818e81bc2dcbdc768 /src/animation/backend/handler.cpp
parente20de2c1fd9d2c022e85c45885585ddc52bd0219 (diff)
Fix AnimationClip crash when removing clips
Similar to ClipAnimators, it is important to take care when using these handles by checking if the frontend components have been destroyed already. Change-Id: I0dc3be94a6f0a7d5b064b864eed6cb2961b36ad9 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/backend/handler.cpp')
-rw-r--r--src/animation/backend/handler.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/animation/backend/handler.cpp b/src/animation/backend/handler.cpp
index daa98ed54..c37db23cf 100644
--- a/src/animation/backend/handler.cpp
+++ b/src/animation/backend/handler.cpp
@@ -147,6 +147,16 @@ void Handler::setBlendedClipAnimatorRunning(const HBlendedClipAnimator &handle,
// The vectors may get outdated when the application removes/deletes an
// animator component in the meantime. Recognize this. This should be
// relatively infrequent so in most cases the vectors will not change at all.
+void Handler::cleanupHandleList(QVector<HAnimationClip> *clips)
+{
+ for (auto it = clips->begin(); it != clips->end(); ) {
+ if (!m_animationClipLoaderManager->data(*it))
+ clips->erase(it);
+ else
+ ++it;
+ }
+}
+
void Handler::cleanupHandleList(QVector<HClipAnimator> *animators)
{
for (auto it = animators->begin(); it != animators->end(); ) {
@@ -182,6 +192,7 @@ QVector<Qt3DCore::QAspectJobPtr> Handler::jobsToExecute(qint64 time)
// queue up a job for them
if (!m_dirtyAnimationClips.isEmpty()) {
qCDebug(HandlerLogic) << "Added LoadAnimationClipJob";
+ cleanupHandleList(&m_dirtyAnimationClips);
m_loadAnimationClipJob->addDirtyAnimationClips(m_dirtyAnimationClips);
jobs.push_back(m_loadAnimationClipJob);
m_dirtyAnimationClips.clear();