aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemanimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickitemanimation.cpp')
-rw-r--r--src/quick/items/qquickitemanimation.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index 23694e2de3..63359a7683 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -230,8 +230,8 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
{
Q_D(QQuickParentAnimation);
- QQuickParentAnimationData *data = new QQuickParentAnimationData;
- QQuickParentAnimationData *viaData = new QQuickParentAnimationData;
+ std::unique_ptr<QQuickParentAnimationData> data(new QQuickParentAnimationData);
+ std::unique_ptr<QQuickParentAnimationData> viaData(new QQuickParentAnimationData);
bool hasExplicit = false;
if (d->target && d->newParent) {
@@ -377,8 +377,8 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
QParallelAnimationGroupJob *ag = new QParallelAnimationGroupJob;
if (d->via)
- viaAction->setAnimAction(viaData);
- targetAction->setAnimAction(data);
+ viaAction->setAnimAction(viaData.release());
+ targetAction->setAnimAction(data.release());
//take care of any child animations
bool valid = d->defaultProperty.isValid();
@@ -405,9 +405,6 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
topLevelGroup->appendAnimation(d->via ? viaAction : targetAction);
}
return initInstance(topLevelGroup);
- } else {
- delete data;
- delete viaData;
}
return nullptr;
}
@@ -532,8 +529,8 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
data->interpolatorType = QMetaType::QReal;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = false;
+ data->fromIsSourced = false;
+ data->fromIsDefined = false;
for (int ii = 0; ii < actions.count(); ++ii) {
QQuickStateAction &action = actions[ii];
@@ -546,7 +543,7 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QQuickStateActions &act
QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator;
if (data->actions.count()) {
animator->setAnimValue(data);
- animator->setFromSourcedValue(&data->fromSourced);
+ animator->setFromIsSourcedValue(&data->fromIsSourced);
} else {
delete data;
}
@@ -867,9 +864,9 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
data->exitInterval = d->duration ? qreal(d->exitDuration) / d->duration : qreal(0);
data->endRotation = d->endRotation;
data->reverse = direction == Backward ? true : false;
- data->fromSourced = false;
- data->fromDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
- data->toDefined = d->path ? true : false;
+ data->fromIsSourced = false;
+ data->fromIsDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
+ data->toIsDefined = d->path ? true : false;
int origModifiedSize = modified.count();
for (int i = 0; i < actions.count(); ++i) {
@@ -888,8 +885,7 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
}
}
- if (target && d->path &&
- (modified.count() > origModifiedSize || data->toDefined)) {
+ if (target && d->path && (modified.count() > origModifiedSize || data->toIsDefined)) {
data->target = target;
data->path = d->path;
data->path->invalidateSequentialHistory();
@@ -900,13 +896,13 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
// treat interruptions specially, otherwise we end up with strange paths
if ((data->reverse || prevData.reverse) && prevData.currentV > 0 && prevData.currentV < 1) {
- if (!data->fromDefined && !data->toDefined && !prevData.painterPath.isEmpty()) {
+ if (!data->fromIsDefined && !data->toIsDefined && !prevData.painterPath.isEmpty()) {
QPointF pathPos = QQuickPath::sequentialPointAt(prevData.painterPath, prevData.pathLength, prevData.attributePoints, prevData.prevBez, prevData.currentV);
if (!prevData.anchorPoint.isNull())
pathPos -= prevData.anchorPoint;
if (pathPos == data->target->position()) { //only treat as interruption if we interrupted ourself
data->painterPath = prevData.painterPath;
- data->toDefined = data->fromDefined = data->fromSourced = true;
+ data->toIsDefined = data->fromIsDefined = data->fromIsSourced = true;
data->prevBez.isValid = false;
data->interruptStart = prevData.currentV;
data->startRotation = prevData.startRotation;
@@ -916,13 +912,13 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
}
}
}
- pa->setFromSourcedValue(&data->fromSourced);
+ pa->setFromIsSourcedValue(&data->fromIsSourced);
pa->setAnimValue(data);
pa->setDuration(d->duration);
pa->setEasingCurve(d->easingCurve);
return initInstance(pa);
} else {
- pa->setFromSourcedValue(nullptr);
+ pa->setFromIsSourcedValue(nullptr);
pa->setAnimValue(nullptr);
delete pa;
delete data;
@@ -942,7 +938,7 @@ void QQuickPathAnimationUpdater::setValue(qreal v)
}
currentV = v;
bool atStart = ((reverse && v == 1.0) || (!reverse && v == 0.0));
- if (!fromSourced && (!fromDefined || !toDefined)) {
+ if (!fromIsSourced && (!fromIsDefined || !toIsDefined)) {
qreal startX = reverse ? toX + anchorPoint.x() : target->x() + anchorPoint.x();
qreal startY = reverse ? toY + anchorPoint.y() : target->y() + anchorPoint.y();
qreal endX = reverse ? target->x() + anchorPoint.x() : toX + anchorPoint.x();
@@ -950,7 +946,7 @@ void QQuickPathAnimationUpdater::setValue(qreal v)
prevBez.isValid = false;
painterPath = path->createPath(QPointF(startX, startY), QPointF(endX, endY), QStringList(), pathLength, attributePoints);
- fromSourced = true;
+ fromIsSourced = true;
}
qreal angle;