summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-04-08 02:31:33 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-04-08 02:48:17 (GMT)
commit5d9f5b0ba76bee4b148e13fd880d87d167e6c68d (patch)
tree862ecb7220c8f1f7a752b19a2d882af89a6c3794
parentdb3fcbbb2368266d60781189648951ff17895b1e (diff)
downloadQt-5d9f5b0ba76bee4b148e13fd880d87d167e6c68d.zip
Qt-5d9f5b0ba76bee4b148e13fd880d87d167e6c68d.tar.gz
Qt-5d9f5b0ba76bee4b148e13fd880d87d167e6c68d.tar.bz2
Prevent Behavior from being triggered on initialization.
Task-number: QTBUG-6332
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp22
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/startup.qml17
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp16
3 files changed, 43 insertions, 12 deletions
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index 53143d5..07b0798 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -137,7 +137,7 @@ public:
Subscription *subscriptions;
QScriptDeclarativeClass::PersistentIdentifier *identifiers;
- void run(Binding *);
+ void run(Binding *, QDeclarativePropertyPrivate::WriteFlags flags);
const char *programData;
Binding *m_bindings;
@@ -147,7 +147,7 @@ public:
void init();
void run(int instr, QDeclarativeContextData *context,
- QDeclarativeDelayedError *error, QObject *scope, QObject *output);
+ QDeclarativeDelayedError *error, QObject *scope, QObject *output, QDeclarativePropertyPrivate::WriteFlags storeFlags);
inline void unsubscribe(int subIndex);
@@ -246,9 +246,9 @@ int QDeclarativeCompiledBindingsPrivate::Binding::propertyIndex()
return property & 0xFFFF;
}
-void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativePropertyPrivate::WriteFlags)
+void QDeclarativeCompiledBindingsPrivate::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
{
- parent->run(this);
+ parent->run(this, flags);
}
void QDeclarativeCompiledBindingsPrivate::Binding::destroy()
@@ -270,13 +270,13 @@ int QDeclarativeCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void
quint32 count = *reeval;
++reeval;
for (quint32 ii = 0; ii < count; ++ii) {
- d->run(d->m_bindings + reeval[ii]);
+ d->run(d->m_bindings + reeval[ii], QDeclarativePropertyPrivate::DontRemoveBinding);
}
}
return -1;
}
-void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
+void QDeclarativeCompiledBindingsPrivate::run(Binding *binding, QDeclarativePropertyPrivate::WriteFlags flags)
{
Q_Q(QDeclarativeCompiledBindings);
@@ -319,12 +319,11 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
vt->read(binding->target, binding->property & 0xFFFF);
QObject *target = vt;
- run(binding->index, context, binding, binding->scope, target);
+ run(binding->index, context, binding, binding->scope, target, flags);
- vt->write(binding->target, binding->property & 0xFFFF,
- QDeclarativePropertyPrivate::DontRemoveBinding);
+ vt->write(binding->target, binding->property & 0xFFFF, flags);
} else {
- run(binding->index, context, binding, binding->scope, binding->target);
+ run(binding->index, context, binding, binding->scope, binding->target, flags);
}
binding->updating = false;
}
@@ -1085,14 +1084,13 @@ static void dumpInstruction(const Instr *instr)
void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QDeclarativeContextData *context, QDeclarativeDelayedError *error,
- QObject *scope, QObject *output)
+ QObject *scope, QObject *output, QDeclarativePropertyPrivate::WriteFlags storeFlags)
{
Q_Q(QDeclarativeCompiledBindings);
error->removeError();
Register registers[32];
- int storeFlags = 0;
QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(context->engine);
Program *program = (Program *)programData;
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml
new file mode 100644
index 0000000..f3ff620
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml
@@ -0,0 +1,17 @@
+import Qt 4.7
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ objectName: "innerRect"
+ height: 100; width: 100; color: "green"
+ property real targetX: 100
+
+ x: targetX
+ Behavior on x {
+ NumberAnimation {}
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 26c8231..4c9c9ca 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -68,6 +68,7 @@ private slots:
void reassignedAnimation();
void disabled();
void dontStart();
+ void startup();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -326,6 +327,21 @@ void tst_qdeclarativebehaviors::dontStart()
delete rect;
}
+void tst_qdeclarativebehaviors::startup()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
+
+ delete rect;
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"