diff options
3 files changed, 29 insertions, 4 deletions
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 8ff1a06c82..6fb36197ef 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -60,7 +60,6 @@ public: , blockRunningChanged(false) {} QDeclarativeProperty property; - QVariant currentValue; QVariant targetValue; QDeclarativeGuard<QDeclarativeAbstractAnimation> animation; bool enabled; @@ -185,7 +184,7 @@ void QDeclarativeBehavior::write(const QVariant &value) if (d->animation->isRunning() && value == d->targetValue) return; - d->currentValue = d->property.read(); + const QVariant ¤tValue = d->property.read(); d->targetValue = value; if (d->animation->qtAnimation()->duration() != -1 @@ -197,7 +196,7 @@ void QDeclarativeBehavior::write(const QVariant &value) QDeclarativeStateOperation::ActionList actions; QDeclarativeAction action; action.property = d->property; - action.fromValue = d->currentValue; + action.fromValue = currentValue; action.toValue = value; actions << action; @@ -213,7 +212,6 @@ void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property) { Q_D(QDeclarativeBehavior); d->property = property; - d->currentValue = property.read(); if (d->animation) d->animation->setDefaultTarget(property); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/valueType.qml b/tests/auto/declarative/qdeclarativebehaviors/data/valueType.qml new file mode 100644 index 0000000000..7bc8297dc7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativebehaviors/data/valueType.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + + color.r: 1 + color.g: 0 + color.b: 1 + + Behavior on color.r { NumberAnimation { duration: 500; } } + + function changeR() { color.r = 0 } +} diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index e84cd580ce..608cdac3a8 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -66,6 +66,7 @@ private slots: void replaceBinding(); //void transitionOverrides(); void group(); + void valueType(); void emptyBehavior(); void explicitSelection(); void nonSelectingBehavior(); @@ -237,6 +238,19 @@ void tst_qdeclarativebehaviors::group() } } +void tst_qdeclarativebehaviors::valueType() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valueType.qml"))); + QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create()); + QVERIFY(rect); + + //QTBUG-20827 + QCOMPARE(rect->color(), QColor::fromRgb(255,0,255)); + + delete rect; +} + void tst_qdeclarativebehaviors::emptyBehavior() { QDeclarativeEngine engine; |