diff options
author | Juan Jose Casafranca <juan.casafranca@kdab.com> | 2018-07-03 11:48:48 +0200 |
---|---|---|
committer | Juan José Casafranca <juan.casafranca@kdab.com> | 2018-07-11 13:30:56 +0000 |
commit | c39e20dcc693b525f2ee2259e864487d664c3856 (patch) | |
tree | c4331e8027cffabe5e96c874a099d1cd0b33b925 /src/animation/frontend | |
parent | cb2405886dadffd3c787f64f2ca02c5f40810b72 (diff) |
Check animator can be played in frontend and backend
We check that the animator can be played in the frontend. Each animator
subclass must implement their own canPlay method.
In the backend we correctly check the clipAnimator can be played
Task-number: QTBUG-69369
Change-Id: If8bca9b73321e2bfdb4d68ddc286df0109ee91f1
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/frontend')
-rw-r--r-- | src/animation/frontend/qabstractclipanimator.cpp | 8 | ||||
-rw-r--r-- | src/animation/frontend/qabstractclipanimator_p.h | 2 | ||||
-rw-r--r-- | src/animation/frontend/qclipanimator.cpp | 9 | ||||
-rw-r--r-- | src/animation/frontend/qclipanimator_p.h | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/animation/frontend/qabstractclipanimator.cpp b/src/animation/frontend/qabstractclipanimator.cpp index ba5d9456b..238dbea8c 100644 --- a/src/animation/frontend/qabstractclipanimator.cpp +++ b/src/animation/frontend/qabstractclipanimator.cpp @@ -57,6 +57,11 @@ QAbstractClipAnimatorPrivate::QAbstractClipAnimatorPrivate() { } +bool QAbstractClipAnimatorPrivate::canPlay() const +{ + return true; +} + /*! \qmltype AbstractClipAnimator \instantiates Qt3DAnimation::QAbstractClipAnimator @@ -234,6 +239,9 @@ void QAbstractClipAnimator::setRunning(bool running) if (d->m_running == running) return; + if (running && !d->canPlay()) + return; + d->m_running = running; emit runningChanged(running); } diff --git a/src/animation/frontend/qabstractclipanimator_p.h b/src/animation/frontend/qabstractclipanimator_p.h index e65ee160c..bf9504909 100644 --- a/src/animation/frontend/qabstractclipanimator_p.h +++ b/src/animation/frontend/qabstractclipanimator_p.h @@ -65,6 +65,8 @@ class QAbstractClipAnimatorPrivate : public Qt3DCore::QComponentPrivate public: QAbstractClipAnimatorPrivate(); + virtual bool canPlay() const; + Q_DECLARE_PUBLIC(QAbstractClipAnimator) Qt3DAnimation::QChannelMapper *m_mapper; diff --git a/src/animation/frontend/qclipanimator.cpp b/src/animation/frontend/qclipanimator.cpp index c14715494..398758820 100644 --- a/src/animation/frontend/qclipanimator.cpp +++ b/src/animation/frontend/qclipanimator.cpp @@ -53,6 +53,15 @@ QClipAnimatorPrivate::QClipAnimatorPrivate() { } +bool QClipAnimatorPrivate::canPlay() const +{ + if (m_clip && m_mapper) + return true; + + qWarning("ClipAnimators need a clip and a mapper to be played"); + return false; +} + /*! \qmltype ClipAnimator \instantiates Qt3DAnimation::QClipAnimator diff --git a/src/animation/frontend/qclipanimator_p.h b/src/animation/frontend/qclipanimator_p.h index fe40ed442..2f6d05b2e 100644 --- a/src/animation/frontend/qclipanimator_p.h +++ b/src/animation/frontend/qclipanimator_p.h @@ -64,6 +64,8 @@ class QClipAnimatorPrivate : public Qt3DAnimation::QAbstractClipAnimatorPrivate public: QClipAnimatorPrivate(); + bool canPlay() const override; + Q_DECLARE_PUBLIC(QClipAnimator) QAbstractAnimationClip *m_clip; |