From 04c4735798cb7ed811c034c3e097dbbf53f28c9e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 11:07:32 +1000 Subject: Fix animation crash. --- src/declarative/util/qmlanimation.cpp | 4 ++++ .../declarative/animations/data/badproperty1.qml | 22 ++++++++++++++++++++++ .../declarative/animations/data/dotproperty.qml | 22 ++++++++++++++++++++++ .../auto/declarative/animations/tst_animations.cpp | 15 +++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tests/auto/declarative/animations/data/badproperty1.qml create mode 100644 tests/auto/declarative/animations/data/dotproperty.qml diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index da26bdd..c4eabfe 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1072,6 +1072,8 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, for (int jj = 0; jj < props.count(); ++jj) { Action myAction; myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; myAction.toValue = d->value; data->actions << myAction; } @@ -1895,6 +1897,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, for (int jj = 0; jj < props.count(); ++jj) { Action myAction; myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; if (d->fromIsDefined) { d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); diff --git a/tests/auto/declarative/animations/data/badproperty1.qml b/tests/auto/declarative/animations/data/badproperty1.qml new file mode 100644 index 0000000..dc35775 --- /dev/null +++ b/tests/auto/declarative/animations/data/badproperty1.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; pen.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: MyRect; to: "red"; properties: "pen.colr"; duration: 1000 } + } +} diff --git a/tests/auto/declarative/animations/data/dotproperty.qml b/tests/auto/declarative/animations/data/dotproperty.qml new file mode 100644 index 0000000..2cfcefe --- /dev/null +++ b/tests/auto/declarative/animations/data/dotproperty.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; pen.color: "blue" } + } + transitions: Transition { + ColorAnimation { properties: "pen.color"; duration: 1000 } + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 1895cef2..a493454 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -12,6 +12,7 @@ public: private slots: void badTypes(); + void badProperties(); //void mixedTypes(); }; @@ -51,6 +52,20 @@ void tst_animations::badTypes() } } +void tst_animations::badProperties() +{ + //don't crash (should be runtime error) + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/badproperty1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } +} + /*//test animating mixed types with property animation //for example, int + real; color + real; etc void tst_animations::mixedTypes() -- cgit v0.12