summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp8
-rw-r--r--src/corelib/animation/qanimationgroup.cpp13
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp6
-rw-r--r--src/corelib/animation/qvariantanimation.cpp6
5 files changed, 19 insertions, 16 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 46b01449d4..b7136dc055 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -220,7 +220,7 @@ QUnifiedTimer::QUnifiedTimer() :
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
currentAnimationIdx(0), insideTick(false), insideRestart(false), consistentTiming(false), slowMode(false),
startTimersPending(false), stopTimerPending(false),
- slowdownFactor(5.0f), profilerCallback(0),
+ slowdownFactor(5.0f), profilerCallback(nullptr),
driverStartTime(0), temporalDrift(0)
{
time.invalidate();
@@ -922,7 +922,7 @@ qint64 QAnimationDriver::elapsed() const
The default animation driver just spins the timer...
*/
QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer)
- : QAnimationDriver(0), m_unified_timer(timer)
+ : QAnimationDriver(nullptr), m_unified_timer(timer)
{
connect(this, SIGNAL(started()), this, SLOT(startTimer()));
connect(this, SIGNAL(stopped()), this, SLOT(stopTimer()));
@@ -1035,7 +1035,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
\sa QVariantAnimation, QAnimationGroup
*/
QAbstractAnimation::QAbstractAnimation(QObject *parent)
- : QObject(*new QAbstractAnimationPrivate, 0)
+ : QObject(*new QAbstractAnimationPrivate, nullptr)
{
// Allow auto-add on reparent
setParent(parent);
@@ -1045,7 +1045,7 @@ QAbstractAnimation::QAbstractAnimation(QObject *parent)
\internal
*/
QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent)
- : QObject(dd, 0)
+ : QObject(dd, nullptr)
{
// Allow auto-add on reparent
setParent(parent);
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index ed40817222..729f55d68f 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -133,7 +133,7 @@ QAbstractAnimation *QAnimationGroup::animationAt(int index) const
if (index < 0 || index >= d->animations.size()) {
qWarning("QAnimationGroup::animationAt: index is out of bounds");
- return 0;
+ return nullptr;
}
return d->animations.at(index);
@@ -195,8 +195,11 @@ void QAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
return;
}
- if (QAnimationGroup *oldGroup = animation->group())
+ if (QAnimationGroup *oldGroup = animation->group()) {
oldGroup->removeAnimation(animation);
+ // ensure we don't insert out of bounds if oldGroup == this
+ index = qMin(index, d->animations.size());
+ }
d->animations.insert(index, animation);
QAbstractAnimationPrivate::get(animation)->group = this;
@@ -240,14 +243,14 @@ QAbstractAnimation *QAnimationGroup::takeAnimation(int index)
Q_D(QAnimationGroup);
if (index < 0 || index >= d->animations.size()) {
qWarning("QAnimationGroup::takeAnimation: no animation at index %d", index);
- return 0;
+ return nullptr;
}
QAbstractAnimation *animation = d->animations.at(index);
- QAbstractAnimationPrivate::get(animation)->group = 0;
+ QAbstractAnimationPrivate::get(animation)->group = nullptr;
// ### removing from list before doing setParent to avoid inifinite recursion
// in ChildRemoved event
d->animations.removeAt(index);
- animation->setParent(0);
+ animation->setParent(nullptr);
d->animationRemoved(index, animation);
return animation;
}
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 2a3572d441..c71a77e073 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -259,7 +259,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState,
QVariantAnimation::updateState(newState, oldState);
- QPropertyAnimation *animToStop = 0;
+ QPropertyAnimation *animToStop = nullptr;
{
static QBasicMutex mutex;
auto locker = qt_unique_lock(mutex);
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 66e346a2fe..98ac04a14f 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -282,7 +282,7 @@ QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs)
if (index < 0 || index > d->animations.size()) {
qWarning("QSequentialAnimationGroup::insertPause: index is out of bounds");
- return 0;
+ return nullptr;
}
QPauseAnimation *pause = new QPauseAnimation(msecs);
@@ -430,7 +430,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter
if (index == -1) {
Q_ASSERT(animations.isEmpty());
currentAnimationIndex = -1;
- currentAnimation = 0;
+ currentAnimation = nullptr;
return;
}
@@ -503,7 +503,7 @@ void QSequentialAnimationGroupPrivate::_q_uncontrolledAnimationFinished()
*/
void QSequentialAnimationGroupPrivate::animationInsertedAt(int index)
{
- if (currentAnimation == 0)
+ if (currentAnimation == nullptr)
setCurrentAnimation(0); // initialize the current animation
if (currentAnimationIndex == index
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 216c015732..98b02f0202 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -209,7 +209,7 @@ void QVariantAnimationPrivate::updateInterpolator()
if (type == currentInterval.end.second.userType())
interpolator = getInterpolator(type);
else
- interpolator = 0;
+ interpolator = nullptr;
//we make sure that the interpolator is always set to something
if (!interpolator)
@@ -445,7 +445,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in
{
QInterpolatorVector *interpolators = registeredInterpolators();
const auto locker = qt_scoped_lock(registeredInterpolatorsMutex);
- QVariantAnimation::Interpolator ret = 0;
+ QVariantAnimation::Interpolator ret = nullptr;
if (interpolationType < interpolators->count()) {
ret = interpolators->at(interpolationType);
if (ret) return ret;
@@ -479,7 +479,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in
case QMetaType::QRectF:
return castToInterpolator(_q_interpolateVariant<QRectF>);
default:
- return 0; //this type is not handled
+ return nullptr; //this type is not handled
}
}