summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation/qanimationgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/animation/qanimationgroup.cpp')
-rw-r--r--src/corelib/animation/qanimationgroup.cpp13
1 files changed, 8 insertions, 5 deletions
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;
}