summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-08-02 05:36:35 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-08-02 05:40:39 (GMT)
commit969daadd245153e8bb6c9a89a51565b83832f484 (patch)
treed09280da58fff20a2d6342fdd3ecccc178e554dc
parent0ea02a0576ebbc9cf8dfa9fb6c8137f2eb261422 (diff)
downloadQt-969daadd245153e8bb6c9a89a51565b83832f484.zip
Qt-969daadd245153e8bb6c9a89a51565b83832f484.tar.gz
Qt-969daadd245153e8bb6c9a89a51565b83832f484.tar.bz2
Correctly apply PropertyChanges when entering an extended state
directly from the base state. Make sure qmlExecuteDeferred is called on the state being extended. Task-number: QTBUG-12559
-rw-r--r--src/declarative/util/qdeclarativestate.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/extendsBug.qml26
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp16
3 files changed, 45 insertions, 1 deletions
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index 9f4cc39..f7dae10 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -358,8 +358,10 @@ QDeclarativeStatePrivate::generateActionList(QDeclarativeStateGroup *group) cons
if (!extends.isEmpty()) {
QList<QDeclarativeState *> states = group->states();
for (int ii = 0; ii < states.count(); ++ii)
- if (states.at(ii)->name() == extends)
+ if (states.at(ii)->name() == extends) {
+ qmlExecuteDeferred(states.at(ii));
applyList = static_cast<QDeclarativeStatePrivate*>(states.at(ii)->d_func())->generateActionList(group);
+ }
}
foreach(QDeclarativeStateOperation *op, operations)
diff --git a/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml
new file mode 100644
index 0000000..a3c4827
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml
@@ -0,0 +1,26 @@
+import Qt 4.7
+
+Rectangle {
+ width: 200
+ height: 200
+
+ Rectangle {
+ id: rect
+ objectName: "greenRect"
+ width: 100
+ height: 100
+ color: "green"
+ }
+
+ states:[
+ State {
+ name: "a"
+ PropertyChanges { target: rect; x: 100 }
+ },
+ State {
+ name: "b"
+ extend:"a"
+ PropertyChanges { target: rect; y: 100 }
+ }
+ ]
+}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 3b6a420..6ae2759 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -139,6 +139,7 @@ private slots:
void urlResolution();
void unnamedWhen();
void returnToBase();
+ void extendsBug();
};
void tst_qdeclarativestates::initTestCase()
@@ -1186,6 +1187,21 @@ void tst_qdeclarativestates::returnToBase()
QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
}
+//QTBUG-12559
+void tst_qdeclarativestates::extendsBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect);
+ QDeclarativeRectangle *greenRect = rect->findChild<QDeclarativeRectangle*>("greenRect");
+
+ rectPrivate->setState("b");
+ QCOMPARE(greenRect->x(), qreal(100));
+ QCOMPARE(greenRect->y(), qreal(100));
+}
QTEST_MAIN(tst_qdeclarativestates)