diff options
Diffstat (limited to 'src/qml/animations')
-rw-r--r-- | src/qml/animations/animations.pri | 18 | ||||
-rw-r--r-- | src/qml/animations/qabstractanimationjob.cpp | 126 | ||||
-rw-r--r-- | src/qml/animations/qabstractanimationjob_p.h | 69 | ||||
-rw-r--r-- | src/qml/animations/qanimationgroupjob.cpp | 124 | ||||
-rw-r--r-- | src/qml/animations/qanimationgroupjob_p.h | 66 | ||||
-rw-r--r-- | src/qml/animations/qanimationjobutil_p.h | 88 | ||||
-rw-r--r-- | src/qml/animations/qcontinuinganimationgroupjob.cpp | 64 | ||||
-rw-r--r-- | src/qml/animations/qcontinuinganimationgroupjob_p.h | 42 | ||||
-rw-r--r-- | src/qml/animations/qparallelanimationgroupjob.cpp | 70 | ||||
-rw-r--r-- | src/qml/animations/qparallelanimationgroupjob_p.h | 42 | ||||
-rw-r--r-- | src/qml/animations/qpauseanimationjob.cpp | 42 | ||||
-rw-r--r-- | src/qml/animations/qpauseanimationjob_p.h | 42 | ||||
-rw-r--r-- | src/qml/animations/qsequentialanimationgroupjob.cpp | 132 | ||||
-rw-r--r-- | src/qml/animations/qsequentialanimationgroupjob_p.h | 49 |
14 files changed, 289 insertions, 685 deletions
diff --git a/src/qml/animations/animations.pri b/src/qml/animations/animations.pri deleted file mode 100644 index a379692567..0000000000 --- a/src/qml/animations/animations.pri +++ /dev/null @@ -1,18 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qabstractanimationjob_p.h \ - $$PWD/qanimationgroupjob_p.h \ - $$PWD/qsequentialanimationgroupjob_p.h \ - $$PWD/qparallelanimationgroupjob_p.h \ - $$PWD/qcontinuinganimationgroupjob_p.h \ - $$PWD/qpauseanimationjob_p.h \ - $$PWD/qanimationjobutil_p.h - -SOURCES += \ - $$PWD/qabstractanimationjob.cpp \ - $$PWD/qanimationgroupjob.cpp \ - $$PWD/qsequentialanimationgroupjob.cpp \ - $$PWD/qparallelanimationgroupjob.cpp \ - $$PWD/qcontinuinganimationgroupjob.cpp \ - $$PWD/qpauseanimationjob.cpp diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index ece2f0d692..a50685ba50 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtCore/qthreadstorage.h> @@ -44,8 +8,7 @@ #include "private/qanimationjobutil_p.h" #include "private/qqmlengine_p.h" #include "private/qqmlglobal_p.h" - -#define DEFAULT_TIMER_INTERVAL 16 +#include "private/qdoubleendedlist_p.h" QT_BEGIN_NAMESPACE @@ -67,6 +30,35 @@ QQmlAnimationTimer::QQmlAnimationTimer() : { } +void QQmlAnimationTimer::unsetJobTimer(QAbstractAnimationJob *animation) +{ + if (!animation) + return; + if (animation->m_timer == this) + animation->m_timer = nullptr; + + if (animation->m_isPause) + runningPauseAnimations.removeOne(animation); + + if (animation->isGroup()) { + QAnimationGroupJob *group = static_cast<QAnimationGroupJob *>(animation); + if (const auto children = group->children()) { + for (auto *child : *children) + unsetJobTimer(child); + } + } +} + +QQmlAnimationTimer::~QQmlAnimationTimer() +{ + for (const auto &animation : std::as_const(animations)) + unsetJobTimer(animation); + for (const auto &animation : std::as_const(animationsToStart)) + unsetJobTimer(animation); + for (const auto &animation : std::as_const(runningPauseAnimations)) + unsetJobTimer(animation); +} + QQmlAnimationTimer *QQmlAnimationTimer::instance(bool create) { QQmlAnimationTimer *inst; @@ -88,7 +80,7 @@ void QQmlAnimationTimer::ensureTimerUpdate() { QUnifiedTimer *instU = QUnifiedTimer::instance(false); if (instU && isPaused) - instU->updateAnimationTimers(-1); + instU->updateAnimationTimers(); } void QQmlAnimationTimer::updateAnimationsTime(qint64 delta) @@ -104,7 +96,7 @@ void QQmlAnimationTimer::updateAnimationsTime(qint64 delta) //when the CPU load is high if (delta) { insideTick = true; - for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { + for (currentAnimationIdx = 0; currentAnimationIdx < animations.size(); ++currentAnimationIdx) { QAbstractAnimationJob *animation = animations.at(currentAnimationIdx); int elapsed = animation->m_totalCurrentTime + (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta); @@ -112,7 +104,7 @@ void QQmlAnimationTimer::updateAnimationsTime(qint64 delta) } if (animationTickDump()) { qDebug() << "***** Dumping Animation Tree ***** ( tick:" << lastTick << "delta:" << delta << ")"; - for (int i = 0; i < animations.count(); ++i) + for (int i = 0; i < animations.size(); ++i) qDebug() << animations.at(i); } insideTick = false; @@ -218,16 +210,16 @@ void QQmlAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animati void QQmlAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation) { + unsetJobTimer(animation); if (animation->userControlDisabled()) return; if (animation->m_isGroup) return; - if (animation->m_isPause) - runningPauseAnimations.removeOne(animation); - else + if (!animation->m_isPause) runningLeafAnimations--; + Q_ASSERT(runningLeafAnimations >= 0); } @@ -261,9 +253,6 @@ QAbstractAnimationJob::QAbstractAnimationJob() , m_currentLoop(0) , m_uncontrolledFinishTime(-1) , m_currentLoopStartTime(0) - , m_nextSibling(nullptr) - , m_previousSibling(nullptr) - , m_wasDeleted(nullptr) , m_hasRegisteredTimer(false) , m_isPause(false) , m_isGroup(false) @@ -277,9 +266,6 @@ QAbstractAnimationJob::QAbstractAnimationJob() QAbstractAnimationJob::~QAbstractAnimationJob() { - if (m_wasDeleted) - *m_wasDeleted = true; - //we can't call stop here. Otherwise we get pure virtual calls if (m_state != Stopped) { State oldState = m_state; @@ -288,8 +274,10 @@ QAbstractAnimationJob::~QAbstractAnimationJob() Q_ASSERT(m_state == Stopped); if (oldState == Running) { - Q_ASSERT(QQmlAnimationTimer::instance() == m_timer); - m_timer->unregisterAnimation(this); + if (m_timer) { + Q_ASSERT(QQmlAnimationTimer::instance(false) == m_timer); + m_timer->unregisterAnimation(this); + } } Q_ASSERT(!m_hasRegisteredTimer); } @@ -314,8 +302,9 @@ void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState) if (m_loopCount == 0) return; - if (!m_timer) - m_timer = QQmlAnimationTimer::instance(); + if (!m_timer) // don't create a timer just to stop the animation + m_timer = QQmlAnimationTimer::instance(newState != Stopped); + Q_ASSERT(m_timer || newState == Stopped); State oldState = m_state; int oldCurrentTime = m_currentTime; @@ -343,8 +332,9 @@ void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState) if (oldState == Running) { if (newState == Paused && m_hasRegisteredTimer) m_timer->ensureTimerUpdate(); - //the animation, is not running any more - m_timer->unregisterAnimation(this); + // the animation is not running any more + if (m_timer) + m_timer->unregisterAnimation(this); } else if (newState == Running) { m_timer->registerAnimation(this, isTopLevel); } @@ -422,7 +412,10 @@ void QAbstractAnimationJob::setDirection(Direction direction) void QAbstractAnimationJob::setLoopCount(int loopCount) { + if (m_loopCount == loopCount) + return; m_loopCount = loopCount; + updateLoopCount(loopCount); } int QAbstractAnimationJob::totalDuration() const @@ -487,8 +480,11 @@ void QAbstractAnimationJob::setCurrentTime(int msecs) RETURN_IF_DELETED(updateCurrentTime(m_currentTime)); - if (m_currentLoop != oldLoop) - currentLoopChanged(); + if (m_currentLoop != oldLoop) { + // CurrentLoop listeners may restart the job if e.g. from has changed. Stopping a job will + // destroy it, so account for that here. + RETURN_IF_DELETED(currentLoopChanged()); + } // All animations are responsible for stopping the animation when their // own end state is reached; in this case the animation is time driven, @@ -526,6 +522,14 @@ void QAbstractAnimationJob::stop() setState(Stopped); } +void QAbstractAnimationJob::complete() +{ + // Simulate the full animation cycle + setState(Running); + setCurrentTime(m_direction == Forward ? duration() : 0); + setState(Stopped); +} + void QAbstractAnimationJob::pause() { if (m_state == Stopped) { @@ -645,7 +649,7 @@ void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeLis void QAbstractAnimationJob::debugAnimation(QDebug d) const { - d << "AbstractAnimationJob(" << hex << (const void *) this << dec << ") state:" + d << "AbstractAnimationJob(" << Qt::hex << (const void *) this << Qt::dec << ") state:" << m_state << "duration:" << duration(); } diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h index 0be6ca96ea..7e0fb00021 100644 --- a/src/qml/animations/qabstractanimationjob_p.h +++ b/src/qml/animations/qabstractanimationjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QABSTRACTANIMATIONJOB_P_H #define QABSTRACTANIMATIONJOB_P_H @@ -52,6 +16,8 @@ // #include <private/qtqmlglobal_p.h> +#include <private/qanimationjobutil_p.h> +#include <private/qdoubleendedlist_p.h> #include <QtCore/QObject> #include <QtCore/private/qabstractanimation_p.h> #include <vector> @@ -64,7 +30,7 @@ class QAnimationGroupJob; class QAnimationJobChangeListener; class QQmlAnimationTimer; -class Q_QML_PRIVATE_EXPORT QAbstractAnimationJob +class Q_QML_EXPORT QAbstractAnimationJob : public QInheritedListNode { Q_DISABLE_COPY(QAbstractAnimationJob) public: @@ -112,6 +78,7 @@ public: void pause(); void resume(); void stop(); + void complete(); enum ChangeType { Completion = 0x01, @@ -123,15 +90,15 @@ public: void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); - QAbstractAnimationJob *nextSibling() const { return m_nextSibling; } - QAbstractAnimationJob *previousSibling() const { return m_previousSibling; } bool isGroup() const { return m_isGroup; } bool isRenderThreadJob() const { return m_isRenderThreadJob; } bool isRenderThreadProxy() const { return m_isRenderThreadProxy; } + SelfDeletable m_selfDeletable; protected: virtual void updateCurrentTime(int) {} + virtual void updateLoopCount(int) {} virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); virtual void updateDirection(QAbstractAnimationJob::Direction direction); virtual void topLevelAnimationLoopChanged() {} @@ -170,11 +137,8 @@ protected: }; std::vector<ChangeListener> changeListeners; - QAbstractAnimationJob *m_nextSibling; - QAbstractAnimationJob *m_previousSibling; QQmlAnimationTimer *m_timer = nullptr; - bool *m_wasDeleted; bool m_hasRegisteredTimer:1; bool m_isPause:1; bool m_isGroup:1; @@ -185,10 +149,10 @@ protected: friend class QQmlAnimationTimer; friend class QAnimationGroupJob; - friend Q_QML_PRIVATE_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); + friend Q_QML_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); }; -class Q_QML_PRIVATE_EXPORT QAnimationJobChangeListener +class Q_QML_EXPORT QAnimationJobChangeListener { public: virtual ~QAnimationJobChangeListener(); @@ -198,13 +162,15 @@ public: virtual void animationCurrentTimeChanged(QAbstractAnimationJob *, int) {} }; -class Q_QML_PRIVATE_EXPORT QQmlAnimationTimer : public QAbstractAnimationTimer +class Q_QML_EXPORT QQmlAnimationTimer : public QAbstractAnimationTimer { Q_OBJECT private: QQmlAnimationTimer(); public: + ~QQmlAnimationTimer(); // must be destructible by QThreadStorage + static QQmlAnimationTimer *instance(); static QQmlAnimationTimer *instance(bool create); @@ -227,7 +193,11 @@ public: void updateAnimationsTime(qint64 timeStep) override; //useful for profiling/debugging - int runningAnimationCount() override { return animations.count(); } +#ifdef QT_QAbstractAnimationTimer_runningAnimationCount_IS_CONST + qsizetype runningAnimationCount() const override { return animations.size(); } +#else + int runningAnimationCount() override { return animations.size(); } +#endif bool hasStartAnimationPending() const { return startAnimationPending; } @@ -250,13 +220,14 @@ private: void registerRunningAnimation(QAbstractAnimationJob *animation); void unregisterRunningAnimation(QAbstractAnimationJob *animation); + void unsetJobTimer(QAbstractAnimationJob *animation); int closestPauseAnimationTimeToFinish(); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes) -Q_QML_PRIVATE_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); +Q_QML_EXPORT QDebug operator<<(QDebug, const QAbstractAnimationJob *job); QT_END_NAMESPACE diff --git a/src/qml/animations/qanimationgroupjob.cpp b/src/qml/animations/qanimationgroupjob.cpp index 66599561fc..d9b7e3f78d 100644 --- a/src/qml/animations/qanimationgroupjob.cpp +++ b/src/qml/animations/qanimationgroupjob.cpp @@ -1,60 +1,44 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qanimationgroupjob_p.h" QT_BEGIN_NAMESPACE QAnimationGroupJob::QAnimationGroupJob() - : QAbstractAnimationJob(), m_firstChild(nullptr), m_lastChild(nullptr) { m_isGroup = true; } +void QAnimationGroupJob::ungroupChild(QAbstractAnimationJob *animation) +{ + Q_ASSERT(animation); + Q_ASSERT(animation->m_group == this); + m_children.remove(animation); + animation->m_group = nullptr; +} + +void QAnimationGroupJob::handleAnimationRemoved(QAbstractAnimationJob *animation) +{ + resetUncontrolledAnimationFinishTime(animation); + if (m_children.isEmpty()) { + m_currentTime = 0; + stop(); + } +} + QAnimationGroupJob::~QAnimationGroupJob() { - clear(); + while (QAbstractAnimationJob *animation = m_children.first()) { + ungroupChild(animation); + handleAnimationRemoved(animation); + delete animation; + } } void QAnimationGroupJob::topLevelAnimationLoopChanged() { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) + for (QAbstractAnimationJob *animation : m_children) animation->fireTopLevelAnimationLoopChanged(); } @@ -63,15 +47,9 @@ void QAnimationGroupJob::appendAnimation(QAbstractAnimationJob *animation) if (QAnimationGroupJob *oldGroup = animation->m_group) oldGroup->removeAnimation(animation); - Q_ASSERT(!animation->previousSibling() && !animation->nextSibling()); - - if (m_lastChild) - m_lastChild->m_nextSibling = animation; - else - m_firstChild = animation; - animation->m_previousSibling = m_lastChild; - m_lastChild = animation; + Q_ASSERT(!animation->isInList()); + m_children.append(animation); animation->m_group = this; animationInserted(animation); } @@ -81,56 +59,34 @@ void QAnimationGroupJob::prependAnimation(QAbstractAnimationJob *animation) if (QAnimationGroupJob *oldGroup = animation->m_group) oldGroup->removeAnimation(animation); - Q_ASSERT(!previousSibling() && !nextSibling()); - - if (m_firstChild) - m_firstChild->m_previousSibling = animation; - else - m_lastChild = animation; - animation->m_nextSibling = m_firstChild; - m_firstChild = animation; + Q_ASSERT(!animation->isInList()); + m_children.prepend(animation); animation->m_group = this; animationInserted(animation); } void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation) { - Q_ASSERT(animation); - Q_ASSERT(animation->m_group == this); - QAbstractAnimationJob *prev = animation->previousSibling(); - QAbstractAnimationJob *next = animation->nextSibling(); - - if (prev) - prev->m_nextSibling = next; - else - m_firstChild = next; - - if (next) - next->m_previousSibling = prev; - else - m_lastChild = prev; - - animation->m_previousSibling = nullptr; - animation->m_nextSibling = nullptr; - - animation->m_group = nullptr; + QAbstractAnimationJob *prev = m_children.prev(animation); + QAbstractAnimationJob *next = m_children.next(animation); + ungroupChild(animation); animationRemoved(animation, prev, next); } void QAnimationGroupJob::clear() { - while (QAbstractAnimationJob *child = firstChild()) { + while (QAbstractAnimationJob *child = m_children.first()) { removeAnimation(child); delete child; } - m_firstChild = nullptr; - m_lastChild = nullptr; + + Q_ASSERT(m_children.isEmpty()); } void QAnimationGroupJob::resetUncontrolledAnimationsFinishTime() { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { if (animation->duration() == -1 || animation->loopCount() < 0) { resetUncontrolledAnimationFinishTime(animation); } @@ -154,11 +110,7 @@ void QAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *an void QAnimationGroupJob::animationRemoved(QAbstractAnimationJob* anim, QAbstractAnimationJob* , QAbstractAnimationJob* ) { - resetUncontrolledAnimationFinishTime(anim); - if (!firstChild()) { - m_currentTime = 0; - stop(); - } + handleAnimationRemoved(anim); } void QAnimationGroupJob::debugChildren(QDebug d) const @@ -169,7 +121,7 @@ void QAnimationGroupJob::debugChildren(QDebug d) const ++indentLevel; QByteArray ind(indentLevel, ' '); - for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) + for (const QAbstractAnimationJob *child : m_children) d << "\n" << ind.constData() << child; } diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h index b01b2f3b36..d276f63868 100644 --- a/src/qml/animations/qanimationgroupjob_p.h +++ b/src/qml/animations/qanimationgroupjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QANIMATIONGROUPJOB_P_H #define QANIMATIONGROUPJOB_P_H @@ -51,17 +15,20 @@ // We mean it. // -#include "private/qabstractanimationjob_p.h" +#include <QtQml/private/qabstractanimationjob_p.h> +#include <QtQml/private/qdoubleendedlist_p.h> #include <QtCore/qdebug.h> QT_REQUIRE_CONFIG(qml_animation); QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QAnimationGroupJob : public QAbstractAnimationJob +class Q_QML_EXPORT QAnimationGroupJob : public QAbstractAnimationJob { Q_DISABLE_COPY(QAnimationGroupJob) public: + using Children = QDoubleEndedList<QAbstractAnimationJob>; + QAnimationGroupJob(); ~QAnimationGroupJob() override; @@ -69,10 +36,10 @@ public: void prependAnimation(QAbstractAnimationJob *animation); void removeAnimation(QAbstractAnimationJob *animation); - QAbstractAnimationJob *firstChild() const { return m_firstChild; } - QAbstractAnimationJob *lastChild() const { return m_lastChild; } + Children *children() { return &m_children; } + const Children *children() const { return &m_children; } - void clear(); + virtual void clear(); //called by QAbstractAnimationJob virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); @@ -85,15 +52,18 @@ protected: //TODO: confirm location of these (should any be moved into QAbstractAnimationJob?) void resetUncontrolledAnimationsFinishTime(); void resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim); - int uncontrolledAnimationFinishTime(QAbstractAnimationJob *anim) const { return anim->m_uncontrolledFinishTime; } + int uncontrolledAnimationFinishTime(const QAbstractAnimationJob *anim) const + { + return anim->m_uncontrolledFinishTime; + } void setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time); void debugChildren(QDebug d) const; -private: - //definition - QAbstractAnimationJob *m_firstChild = nullptr; - QAbstractAnimationJob *m_lastChild = nullptr; + void ungroupChild(QAbstractAnimationJob *animation); + void handleAnimationRemoved(QAbstractAnimationJob *animation); + + Children m_children; }; QT_END_NAMESPACE diff --git a/src/qml/animations/qanimationjobutil_p.h b/src/qml/animations/qanimationjobutil_p.h index e3d6fe9178..fb323d7c89 100644 --- a/src/qml/animations/qanimationjobutil_p.h +++ b/src/qml/animations/qanimationjobutil_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QANIMATIONJOBUTIL_P_H #define QANIMATIONJOBUTIL_P_H @@ -51,20 +15,52 @@ // We mean it. // +#include <QtCore/qcompilerdetection.h> +#include <QtCore/qtconfigmacros.h> + +#include <type_traits> + QT_REQUIRE_CONFIG(qml_animation); -#define RETURN_IF_DELETED(func) \ -{ \ - bool *prevWasDeleted = m_wasDeleted; \ +#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU_ONLY >= 1300 +# define ACTION_IF_DISABLE_DANGLING_POINTER_WARNING QT_WARNING_DISABLE_GCC("-Wdangling-pointer") +#else +# define ACTION_IF_DISABLE_DANGLING_POINTER_WARNING +#endif + +// SelfDeletable is used for self-destruction detection along with +// ACTION_IF_DELETED and RETURN_IF_DELETED macros. While using, the objects +// under test should have a member m_selfDeletable of type SelfDeletable +struct SelfDeletable { + ~SelfDeletable() { + if (m_wasDeleted) + *m_wasDeleted = true; + } + bool *m_wasDeleted = nullptr; +}; + +// \param p pointer to object under test, which should have a member m_selfDeletable of type SelfDeletable +// \param func statements or functions that to be executed under test. +// \param action post process if p was deleted under test. +#define ACTION_IF_DELETED(p, func, action) \ +do { \ + QT_WARNING_PUSH \ + ACTION_IF_DISABLE_DANGLING_POINTER_WARNING \ + static_assert(std::is_same<decltype((p)->m_selfDeletable), SelfDeletable>::value, "m_selfDeletable must be SelfDeletable");\ + bool *prevWasDeleted = (p)->m_selfDeletable.m_wasDeleted; \ bool wasDeleted = false; \ - m_wasDeleted = &wasDeleted; \ - func; \ + (p)->m_selfDeletable.m_wasDeleted = &wasDeleted; \ + {func;} \ if (wasDeleted) { \ if (prevWasDeleted) \ *prevWasDeleted = true; \ - return; \ + {action;} \ } \ - m_wasDeleted = prevWasDeleted; \ -} + (p)->m_selfDeletable.m_wasDeleted = prevWasDeleted; \ + QT_WARNING_POP \ +} while (false) + +#define RETURN_IF_DELETED(func) \ +ACTION_IF_DELETED(this, func, return) #endif // QANIMATIONJOBUTIL_P_H diff --git a/src/qml/animations/qcontinuinganimationgroupjob.cpp b/src/qml/animations/qcontinuinganimationgroupjob.cpp index 10096bf19c..892bfc6fdb 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob.cpp +++ b/src/qml/animations/qcontinuinganimationgroupjob.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Jolla Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qcontinuinganimationgroupjob_p.h" #include "private/qanimationjobutil_p.h" @@ -52,9 +16,8 @@ QContinuingAnimationGroupJob::~QContinuingAnimationGroupJob() void QContinuingAnimationGroupJob::updateCurrentTime(int /*currentTime*/) { - Q_ASSERT(firstChild()); - - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + Q_ASSERT(!m_children.isEmpty()); + for (QAbstractAnimationJob *animation : m_children) { if (animation->state() == state()) { RETURN_IF_DELETED(animation->setCurrentTime(m_currentTime)); } @@ -68,23 +31,23 @@ void QContinuingAnimationGroupJob::updateState(QAbstractAnimationJob::State newS switch (newState) { case Stopped: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) + for (QAbstractAnimationJob *animation : m_children) animation->stop(); break; case Paused: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) + for (QAbstractAnimationJob *animation : m_children) if (animation->isRunning()) animation->pause(); break; case Running: - if (!firstChild()) { + if (m_children.isEmpty()) { stop(); return; } - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - resetUncontrolledAnimationFinishTime(animation); + for (QAbstractAnimationJob *animation : m_children) { + RETURN_IF_DELETED(resetUncontrolledAnimationFinishTime(animation)); animation->setDirection(m_direction); - animation->start(); + RETURN_IF_DELETED(animation->start()); } break; } @@ -93,9 +56,8 @@ void QContinuingAnimationGroupJob::updateState(QAbstractAnimationJob::State newS void QContinuingAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction) { if (!isStopped()) { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) animation->setDirection(direction); - } } } @@ -104,7 +66,7 @@ void QContinuingAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat Q_ASSERT(animation && (animation->duration() == -1)); int uncontrolledRunningCount = 0; - for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) { + for (QAbstractAnimationJob *child : m_children) { if (child == animation) setUncontrolledAnimationFinishTime(animation, animation->currentTime()); else if (uncontrolledAnimationFinishTime(child) == -1) @@ -120,7 +82,7 @@ void QContinuingAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat void QContinuingAnimationGroupJob::debugAnimation(QDebug d) const { - d << "ContinuingAnimationGroupJob(" << hex << (const void *) this << dec << ")"; + d << "ContinuingAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")"; debugChildren(d); } diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h index c67b8d39ad..1112262d4b 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob_p.h +++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Jolla Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QCONTINUINGANIMATIONGROUPJOB_P_H #define QCONTINUINGANIMATIONGROUPJOB_P_H @@ -57,7 +21,7 @@ QT_REQUIRE_CONFIG(qml_animation); QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QContinuingAnimationGroupJob : public QAnimationGroupJob +class Q_QML_EXPORT QContinuingAnimationGroupJob : public QAnimationGroupJob { Q_DISABLE_COPY(QContinuingAnimationGroupJob) public: diff --git a/src/qml/animations/qparallelanimationgroupjob.cpp b/src/qml/animations/qparallelanimationgroupjob.cpp index 700fdf9fd9..4cd63eb6d6 100644 --- a/src/qml/animations/qparallelanimationgroupjob.cpp +++ b/src/qml/animations/qparallelanimationgroupjob.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qparallelanimationgroupjob_p.h" #include "private/qanimationjobutil_p.h" @@ -57,7 +21,7 @@ int QParallelAnimationGroupJob::duration() const { int ret = 0; - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (const QAbstractAnimationJob *animation : m_children) { int currentDuration = animation->totalDuration(); if (currentDuration == -1) return -1; // Undetermined length @@ -69,7 +33,7 @@ int QParallelAnimationGroupJob::duration() const void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/) { - if (!firstChild()) + if (m_children.isEmpty()) return; if (m_currentLoop > m_previousLoop) { @@ -79,21 +43,21 @@ void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/) // For an uncontrolled parallel group, we need to simulate the end of running animations. // As uncontrolled animation finish time is already reset for this next loop, we pick the // longest of the known stop times. - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { int currentDuration = animation->totalDuration(); if (currentDuration >= 0) dura = qMax(dura, currentDuration); } } if (dura > 0) { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { if (!animation->isStopped()) RETURN_IF_DELETED(animation->setCurrentTime(dura)); // will stop } } } else if (m_currentLoop < m_previousLoop) { // simulate completion of the loop seeking backwards - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { //we need to make sure the animation is in the right state //and then rewind it applyGroupState(animation); @@ -103,7 +67,7 @@ void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/) } // finally move into the actual time of the current loop - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { const int dura = animation->totalDuration(); //if the loopcount is bigger we should always start all animations if (m_currentLoop > m_previousLoop @@ -130,24 +94,24 @@ void QParallelAnimationGroupJob::updateState(QAbstractAnimationJob::State newSta switch (newState) { case Stopped: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) + for (QAbstractAnimationJob *animation : m_children) animation->stop(); break; case Paused: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) + for (QAbstractAnimationJob *animation : m_children) if (animation->isRunning()) animation->pause(); break; case Running: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { if (oldState == Stopped) { animation->stop(); m_previousLoop = m_direction == Forward ? 0 : m_loopCount - 1; } - resetUncontrolledAnimationFinishTime(animation); + RETURN_IF_DELETED(resetUncontrolledAnimationFinishTime(animation)); animation->setDirection(m_direction); if (shouldAnimationStart(animation, oldState == Stopped)) - animation->start(); + RETURN_IF_DELETED(animation->start()); } break; } @@ -188,7 +152,7 @@ void QParallelAnimationGroupJob::updateDirection(QAbstractAnimationJob::Directio { //we need to update the direction of the current animation if (!isStopped()) { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + for (QAbstractAnimationJob *animation : m_children) { animation->setDirection(direction); } } else { @@ -208,7 +172,7 @@ void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimatio Q_ASSERT(animation && (animation->duration() == -1 || animation->loopCount() < 0)); int uncontrolledRunningCount = 0; - for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) { + for (QAbstractAnimationJob *child : m_children) { if (child == animation) { setUncontrolledAnimationFinishTime(animation, animation->currentTime()); } else if (child->duration() == -1 || child->loopCount() < 0) { @@ -222,7 +186,7 @@ void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimatio int maxDuration = 0; bool running = false; - for (QAbstractAnimationJob *job = firstChild(); job; job = job->nextSibling()) { + for (QAbstractAnimationJob *job : m_children) { if (job->state() == Running) running = true; maxDuration = qMax(maxDuration, job->totalDuration()); @@ -239,7 +203,7 @@ void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimatio void QParallelAnimationGroupJob::debugAnimation(QDebug d) const { - d << "ParallelAnimationGroupJob(" << hex << (const void *) this << dec << ")"; + d << "ParallelAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")"; debugChildren(d); } diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h index 0265fe3274..c4708a8e5d 100644 --- a/src/qml/animations/qparallelanimationgroupjob_p.h +++ b/src/qml/animations/qparallelanimationgroupjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QPARALLELANIMATIONGROUPJOB_P_H #define QPARALLELANIMATIONGROUPJOB_P_H @@ -57,7 +21,7 @@ QT_REQUIRE_CONFIG(qml_animation); QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob +class Q_QML_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob { Q_DISABLE_COPY(QParallelAnimationGroupJob) public: diff --git a/src/qml/animations/qpauseanimationjob.cpp b/src/qml/animations/qpauseanimationjob.cpp index 0652ed578b..c088b0d351 100644 --- a/src/qml/animations/qpauseanimationjob.cpp +++ b/src/qml/animations/qpauseanimationjob.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qpauseanimationjob_p.h" @@ -67,7 +31,7 @@ void QPauseAnimationJob::updateCurrentTime(int) void QPauseAnimationJob::debugAnimation(QDebug d) const { - d << "PauseAnimationJob(" << hex << (const void *) this << dec << ")" << "duration:" << m_duration; + d << "PauseAnimationJob(" << Qt::hex << (const void *) this << Qt::dec << ")" << "duration:" << m_duration; } QT_END_NAMESPACE diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h index 6c9bbf0dab..e08186e165 100644 --- a/src/qml/animations/qpauseanimationjob_p.h +++ b/src/qml/animations/qpauseanimationjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QPAUSEANIMATIONJOB_P_H #define QPAUSEANIMATIONJOB_P_H @@ -57,7 +21,7 @@ QT_REQUIRE_CONFIG(qml_animation); QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QPauseAnimationJob : public QAbstractAnimationJob +class Q_QML_EXPORT QPauseAnimationJob : public QAbstractAnimationJob { Q_DISABLE_COPY(QPauseAnimationJob) public: diff --git a/src/qml/animations/qsequentialanimationgroupjob.cpp b/src/qml/animations/qsequentialanimationgroupjob.cpp index 22e20d9268..cc2c535031 100644 --- a/src/qml/animations/qsequentialanimationgroupjob.cpp +++ b/src/qml/animations/qsequentialanimationgroupjob.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qsequentialanimationgroupjob_p.h" #include "private/qpauseanimationjob_p.h" @@ -66,11 +30,12 @@ bool QSequentialAnimationGroupJob::atEnd() const const int animTotalCurrentTime = m_currentAnimation->currentTime(); return (m_currentLoop == m_loopCount - 1 && m_direction == Forward - && !m_currentAnimation->nextSibling() + && !m_children.next(m_currentAnimation) && animTotalCurrentTime == animationActualTotalDuration(m_currentAnimation)); } -int QSequentialAnimationGroupJob::animationActualTotalDuration(QAbstractAnimationJob *anim) const +int QSequentialAnimationGroupJob::animationActualTotalDuration( + const QAbstractAnimationJob *anim) const { int ret = anim->totalDuration(); if (ret == -1) { @@ -84,13 +49,12 @@ int QSequentialAnimationGroupJob::animationActualTotalDuration(QAbstractAnimatio QSequentialAnimationGroupJob::AnimationIndex QSequentialAnimationGroupJob::indexForCurrentTime() const { - Q_ASSERT(firstChild()); + Q_ASSERT(!m_children.isEmpty()); AnimationIndex ret; - QAbstractAnimationJob *anim = nullptr; int duration = 0; - for (anim = firstChild(); anim; anim = anim->nextSibling()) { + for (const QAbstractAnimationJob *anim : m_children) { duration = animationActualTotalDuration(anim); // 'animation' is the current animation if one of these reasons is true: @@ -116,7 +80,7 @@ QSequentialAnimationGroupJob::AnimationIndex QSequentialAnimationGroupJob::index // 1. the duration of the group is undefined and we passed its actual duration // 2. there are only 0-duration animations in the group ret.timeOffset -= duration; - ret.animation = lastChild(); + ret.animation = m_children.last(); return ret; } @@ -125,17 +89,17 @@ void QSequentialAnimationGroupJob::restart() // restarting the group by making the first/last animation the current one if (m_direction == Forward) { m_previousLoop = 0; - if (m_currentAnimation == firstChild()) + if (m_currentAnimation == m_children.first()) activateCurrentAnimation(); else - setCurrentAnimation(firstChild()); + setCurrentAnimation(m_children.first()); } else { // direction == Backward m_previousLoop = m_loopCount - 1; - if (m_currentAnimation == lastChild()) + if (m_currentAnimation == m_children.last()) activateCurrentAnimation(); else - setCurrentAnimation(lastChild()); + setCurrentAnimation(m_children.last()); } } @@ -143,21 +107,22 @@ void QSequentialAnimationGroupJob::advanceForwards(const AnimationIndex &newAnim { if (m_previousLoop < m_currentLoop) { // we need to fast forward to the end - for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->nextSibling()) { + for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = m_children.next(anim)) { RETURN_IF_DELETED(setCurrentAnimation(anim, true)); RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim))); } // this will make sure the current animation is reset to the beginning - if (firstChild() && !firstChild()->nextSibling()) { //count == 1 + if (m_children.count() == 1) { // we need to force activation because setCurrentAnimation will have no effect RETURN_IF_DELETED(activateCurrentAnimation()); } else { - RETURN_IF_DELETED(setCurrentAnimation(firstChild(), true)); + RETURN_IF_DELETED(setCurrentAnimation(m_children.first(), true)); } } // and now we need to fast forward from the current position to - for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->nextSibling()) { //### WRONG, + for (QAbstractAnimationJob *anim = m_currentAnimation; + anim && anim != newAnimationIndex.animation; anim = m_children.next(anim)) { //### WRONG, RETURN_IF_DELETED(setCurrentAnimation(anim, true)); RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim))); } @@ -168,21 +133,23 @@ void QSequentialAnimationGroupJob::rewindForwards(const AnimationIndex &newAnima { if (m_previousLoop > m_currentLoop) { // we need to fast rewind to the beginning - for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->previousSibling()) { + for (QAbstractAnimationJob *anim = m_currentAnimation; anim; + anim = m_children.prev(anim)) { RETURN_IF_DELETED(setCurrentAnimation(anim, true)); RETURN_IF_DELETED(anim->setCurrentTime(0)); } // this will make sure the current animation is reset to the end - if (lastChild() && !lastChild()->previousSibling()) { //count == 1 + if (m_children.count() == 1) { //count == 1 // we need to force activation because setCurrentAnimation will have no effect RETURN_IF_DELETED(activateCurrentAnimation()); } else { - RETURN_IF_DELETED(setCurrentAnimation(lastChild(), true)); + RETURN_IF_DELETED(setCurrentAnimation(m_children.last(), true)); } } // and now we need to fast rewind from the current position to - for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->previousSibling()) { + for (QAbstractAnimationJob *anim = m_currentAnimation; + anim && anim != newAnimationIndex.animation; anim = m_children.prev(anim)) { RETURN_IF_DELETED(setCurrentAnimation(anim, true)); RETURN_IF_DELETED(anim->setCurrentTime(0)); } @@ -193,7 +160,7 @@ int QSequentialAnimationGroupJob::duration() const { int ret = 0; - for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) { + for (const QAbstractAnimationJob *anim : m_children) { const int currentDuration = anim->totalDuration(); if (currentDuration == -1) return -1; // Undetermined length @@ -204,6 +171,15 @@ int QSequentialAnimationGroupJob::duration() const return ret; } +void QSequentialAnimationGroupJob::clear() +{ + m_previousLoop = 0; + QAnimationGroupJob::clear(); + + // clear() should call removeAnimation(), which will clear m_currentAnimation, eventually. + Q_ASSERT(m_currentAnimation == nullptr); +} + void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime) { if (!m_currentAnimation) @@ -237,7 +213,7 @@ void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime) } else { //the only case where currentAnimation could be null //is when all animations have been removed - Q_ASSERT(!firstChild()); + Q_ASSERT(m_children.isEmpty()); m_currentTime = 0; RETURN_IF_DELETED(stop()); } @@ -279,10 +255,11 @@ void QSequentialAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direct m_currentAnimation->setDirection(direction); } -void QSequentialAnimationGroupJob::setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate) +void QSequentialAnimationGroupJob::setCurrentAnimation( + const QAbstractAnimationJob *anim, bool intermediate) { if (!anim) { - Q_ASSERT(!firstChild()); + Q_ASSERT(m_children.isEmpty()); m_currentAnimation = nullptr; return; } @@ -294,7 +271,12 @@ void QSequentialAnimationGroupJob::setCurrentAnimation(QAbstractAnimationJob *an if (m_currentAnimation) m_currentAnimation->stop(); - m_currentAnimation = anim; + // Assert that the animation passed as argument is actually part of this group ... + Q_ASSERT(m_children.contains(anim)); + + // ... as then this const_cast is just a shortcut for looking up the non-const + // pointer in the linked list of jobs. + m_currentAnimation = const_cast<QAbstractAnimationJob *>(anim); activateCurrentAnimation(intermediate); } @@ -328,10 +310,10 @@ void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat int totalTime = currentTime(); if (m_direction == Forward) { // set the current animation to be the next one - if (m_currentAnimation->nextSibling()) - setCurrentAnimation(m_currentAnimation->nextSibling()); + if (auto *anim = m_children.next(m_currentAnimation)) + RETURN_IF_DELETED(setCurrentAnimation(anim)); - for (QAbstractAnimationJob *a = animation->nextSibling(); a; a = a->nextSibling()) { + for (QAbstractAnimationJob *a = m_children.next(animation); a; a = m_children.next(a)) { int dur = a->duration(); if (dur == -1) { totalTime = -1; @@ -343,10 +325,10 @@ void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat } else { // set the current animation to be the previous one - if (m_currentAnimation->previousSibling()) - setCurrentAnimation(m_currentAnimation->previousSibling()); + if (auto *anim = m_children.prev(m_currentAnimation)) + RETURN_IF_DELETED(setCurrentAnimation(anim)); - for (QAbstractAnimationJob *a = animation->previousSibling(); a; a = a->previousSibling()) { + for (QAbstractAnimationJob *a = m_children.prev(animation); a; a = m_children.prev(a)) { int dur = a->duration(); if (dur == -1) { totalTime = -1; @@ -365,12 +347,12 @@ void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat void QSequentialAnimationGroupJob::animationInserted(QAbstractAnimationJob *anim) { if (m_currentAnimation == nullptr) - setCurrentAnimation(firstChild()); // initialize the current animation + RETURN_IF_DELETED(setCurrentAnimation(m_children.first())); // initialize the current animation - if (m_currentAnimation == anim->nextSibling() + if (m_currentAnimation == m_children.next(anim) && m_currentAnimation->currentTime() == 0 && m_currentAnimation->currentLoop() == 0) { //in this case we simply insert the animation before the current one has actually started - setCurrentAnimation(anim); + RETURN_IF_DELETED(setCurrentAnimation(anim)); } // TODO @@ -389,16 +371,16 @@ void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, bool removingCurrent = anim == m_currentAnimation; if (removingCurrent) { if (next) - setCurrentAnimation(next); //let's try to take the next one + RETURN_IF_DELETED(setCurrentAnimation(next)); //let's try to take the next one else if (prev) - setCurrentAnimation(prev); + RETURN_IF_DELETED(setCurrentAnimation(prev)); else// case all animations were removed - setCurrentAnimation(nullptr); + RETURN_IF_DELETED(setCurrentAnimation(nullptr)); } // duration of the previous animations up to the current animation m_currentTime = 0; - for (QAbstractAnimationJob *job = firstChild(); job; job = job->nextSibling()) { + for (QAbstractAnimationJob *job : m_children) { if (job == m_currentAnimation) break; m_currentTime += animationActualTotalDuration(job); @@ -417,7 +399,7 @@ void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, void QSequentialAnimationGroupJob::debugAnimation(QDebug d) const { - d << "SequentialAnimationGroupJob(" << hex << (const void *) this << dec << ")" << "currentAnimation:" << (void *)m_currentAnimation; + d << "SequentialAnimationGroupJob(" << Qt::hex << (const void *) this << Qt::dec << ")" << "currentAnimation:" << (void *)m_currentAnimation; debugChildren(d); } diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h index 13f9806be1..c7d4319b4d 100644 --- a/src/qml/animations/qsequentialanimationgroupjob_p.h +++ b/src/qml/animations/qsequentialanimationgroupjob_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H #define QSEQUENTIALANIMATIONGROUPJOB_P_H @@ -58,7 +22,7 @@ QT_REQUIRE_CONFIG(qml_animation); QT_BEGIN_NAMESPACE class QPauseAnimationJob; -class Q_QML_PRIVATE_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob +class Q_QML_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob { Q_DISABLE_COPY(QSequentialAnimationGroupJob) public: @@ -68,6 +32,7 @@ public: int duration() const override; QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; } + void clear() override; protected: void updateCurrentTime(int) override; @@ -84,13 +49,13 @@ private: // Note that the index semantic is slightly different depending on the direction. bool afterCurrent = false; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same int timeOffset = 0; // time offset when the animation at index starts. - QAbstractAnimationJob *animation = nullptr; //points to the animation at timeOffset + const QAbstractAnimationJob *animation = nullptr; //points to the animation at timeOffset }; - int animationActualTotalDuration(QAbstractAnimationJob *anim) const; + int animationActualTotalDuration(const QAbstractAnimationJob *anim) const; AnimationIndex indexForCurrentTime() const; - void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false); + void setCurrentAnimation(const QAbstractAnimationJob *anim, bool intermediate = false); void activateCurrentAnimation(bool intermediate = false); void animationInserted(QAbstractAnimationJob *anim) override; |