diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-05-14 03:15:08 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-05-14 03:15:08 (GMT) |
commit | 5cd963d2628ed7c01d331cdad03b4d77161c8b93 (patch) | |
tree | 42301ae7c37afb47b1daf897ed185e419a247304 | |
parent | 873f755d1f40619174de0436dba293729f87bac9 (diff) | |
download | Qt-5cd963d2628ed7c01d331cdad03b4d77161c8b93.zip Qt-5cd963d2628ed7c01d331cdad03b4d77161c8b93.tar.gz Qt-5cd963d2628ed7c01d331cdad03b4d77161c8b93.tar.bz2 |
Fix crash in ParentAnimation.
copyOriginals plays with the order of the revertList, which messes up
the assumptions of ParentAnimation. The full fix will require some
rearchitecting of how the states and transitions handle "related"
actions, but for now this fixes the crash.
Reverting to the base state has also been fixed.
Task-number: QTBUG-10671, QTBUG-10676
-rw-r--r-- | src/declarative/util/qdeclarativeanimation.cpp | 14 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertychanges.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations_p.h | 3 |
6 files changed, 16 insertions, 13 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 0f7c946..67440b6 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2536,13 +2536,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, viaData->pc << vpc; viaData->actions << myAction; QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent(); + QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); //### this mirrors the logic in QDeclarativeParentChange. bool ok; @@ -2583,9 +2583,9 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { qreal w = target->width(); qreal h = target->height(); - if (pc->widthIsSet()) + if (pc->widthIsSet() && i < actions.size() - 1) w = actions[++i].toValue.toReal(); - if (pc->heightIsSet()) + if (pc->heightIsSet() && i < actions.size() - 1) h = actions[++i].toValue.toReal(); const QPointF &transformOrigin = d->computeTransformOrigin(target->transformOrigin(), w,h); diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index a22c756..12fef36 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -179,7 +179,7 @@ public: reverseExpression = rewindExpression; } - virtual void copyOriginals(QDeclarativeActionEvent *other) + /*virtual void copyOriginals(QDeclarativeActionEvent *other) { QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other); saveCurrentValues(); @@ -190,7 +190,7 @@ public: ownedExpression = rsh->ownedExpression; rsh->ownedExpression = 0; } - } + }*/ virtual void rewind() { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index ea209aa..b5f7900 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -390,12 +390,13 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit if (action.event->override(event)) { found = true; - if (action.event != d->revertList.at(jj).event) { + if (action.event != d->revertList.at(jj).event && action.event->needsCopy()) { action.event->copyOriginals(d->revertList.at(jj).event); QDeclarativeSimpleAction r(action); additionalReverts << r; d->revertList.removeAt(jj); + --jj; } else if (action.event->isRewindable()) //###why needed? action.event->saveCurrentValues(); diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index 0ba67b0..25715c6 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -96,6 +96,7 @@ public: virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); virtual void saveOriginals() {} + virtual bool needsCopy() { return false; } virtual void copyOriginals(QDeclarativeActionEvent *) {} virtual bool isRewindable() { return isReversable(); } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index a93a25d..a6fcaf3 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -408,7 +408,7 @@ void QDeclarativeParentChange::saveOriginals() d->origStackBefore = d->rewindStackBefore; } -void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) +/*void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) { Q_D(QDeclarativeParentChange); QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(other); @@ -417,7 +417,7 @@ void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) d->origStackBefore = pc->d_func()->rewindStackBefore; saveCurrentValues(); -} +}*/ void QDeclarativeParentChange::execute(Reason) { diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index e22c1e2..21a86f5 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -107,7 +107,7 @@ public: virtual ActionList actions(); virtual void saveOriginals(); - virtual void copyOriginals(QDeclarativeActionEvent*); + //virtual void copyOriginals(QDeclarativeActionEvent*); virtual void execute(Reason reason = ActualChange); virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); @@ -277,6 +277,7 @@ public: virtual bool override(QDeclarativeActionEvent*other); virtual bool changesBindings(); virtual void saveOriginals(); + virtual bool needsCopy() { return true; } virtual void copyOriginals(QDeclarativeActionEvent*); virtual void clearBindings(); virtual void rewind(); |