summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Jose Casafranca <juan.casafranca@kdab.com>2018-07-09 16:02:11 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-03-28 09:28:16 +0000
commite84d8d2a81eb81f9b1ea9f40d4da36d09a97b246 (patch)
treec70705841b9df82042a3430ab02da330ce982a12
parentb79e4a8b2a8783fc9eeaaa36e710adf2fb8c7879 (diff)
Dont play animations that are disabled
Change-Id: I5293ff8d16c511de79c4583783b238154af32f61 Task-number: QTBUG-69373 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/animation/backend/findrunningclipanimatorsjob.cpp2
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp56
2 files changed, 49 insertions, 9 deletions
diff --git a/src/animation/backend/findrunningclipanimatorsjob.cpp b/src/animation/backend/findrunningclipanimatorsjob.cpp
index b55c84e77..fde3f7db8 100644
--- a/src/animation/backend/findrunningclipanimatorsjob.cpp
+++ b/src/animation/backend/findrunningclipanimatorsjob.cpp
@@ -65,6 +65,8 @@ void FindRunningClipAnimatorsJob::run()
for (const auto &clipAnimatorHandle : qAsConst(m_clipAnimatorHandles)) {
ClipAnimator *clipAnimator = clipAnimatorManager->data(clipAnimatorHandle);
Q_ASSERT(clipAnimator);
+ if (!clipAnimator->isEnabled())
+ continue;
const bool canRun = clipAnimator->canRun();
const bool running = clipAnimator->isRunning();
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
index ce37ffc76..50c0eb524 100644
--- a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
+++ b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
@@ -120,14 +120,14 @@ private Q_SLOTS:
QTest::addColumn<QVector<HClipAnimator>>("dirtyClipAnimators");
QTest::addColumn<MappingDataResults>("expectedResults");
- Handler *handler;
- AnimationClip *clip;
- ClipAnimator *animator;
- QVector<HClipAnimator> dirtyClipAnimators;
- ChannelMapper *channelMapper;
- MappingDataResults expectedResults;
{
+ Handler *handler;
+ AnimationClip *clip;
+ ClipAnimator *animator;
+ QVector<HClipAnimator> dirtyClipAnimators;
+ ChannelMapper *channelMapper;
+ MappingDataResults expectedResults;
handler = new Handler();
clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json"));
@@ -150,6 +150,7 @@ private Q_SLOTS:
channelMapper = createChannelMapper(handler, QVector<Qt3DCore::QNodeId>() << channelMapping->peerId());
animator->setMapperId(channelMapper->peerId());
animator->setRunning(true); // Has to be marked as running for the job to process it
+ animator->setEnabled(true); // Has to be marked as enabled for the job to process it
const ComponentIndices locationIndices = { 0, 1, 2 };
MappingData expectedMapping;
@@ -160,9 +161,46 @@ private Q_SLOTS:
expectedResults.insert(animator, QVector<MappingData>() << expectedMapping);
QTest::newRow("single mapping")
- << handler
- << dirtyClipAnimators
- << expectedResults;
+ << handler
+ << dirtyClipAnimators
+ << expectedResults;
+ }
+
+ {
+ Handler *handler;
+ AnimationClip *clip;
+ ClipAnimator *animator;
+ QVector<HClipAnimator> dirtyClipAnimators;
+ ChannelMapper *channelMapper;
+ MappingDataResults expectedResults;
+ handler = new Handler();
+ clip = createAnimationClipLoader(handler, QUrl("qrc:/clip1.json"));
+
+ const qint64 globalStartTimeNS = 0;
+ const int loops = 1;
+ animator = createClipAnimator(handler, globalStartTimeNS, loops);
+ animator->setClipId(clip->peerId());
+ dirtyClipAnimators = (QVector<HClipAnimator>()
+ << handler->clipAnimatorManager()->getOrAcquireHandle(animator->peerId()));
+
+ auto channelMapping = createChannelMapping(handler,
+ QLatin1String("Location"),
+ Qt3DCore::QNodeId::createId(),
+ QLatin1String("translation"),
+ "translation",
+ static_cast<int>(QVariant::Vector3D));
+ QVector<ChannelMapping *> channelMappings;
+ channelMappings.push_back(channelMapping);
+
+ channelMapper = createChannelMapper(handler, QVector<Qt3DCore::QNodeId>() << channelMapping->peerId());
+ animator->setMapperId(channelMapper->peerId());
+ animator->setRunning(true); // Has to be marked as running for the job to process it
+ animator->setEnabled(false); // Has to be marked as enabled for the job to process it
+
+ QTest::newRow("disabled animator")
+ << handler
+ << dirtyClipAnimators
+ << expectedResults;
}
}