summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp6
-rw-r--r--tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml20
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp28
3 files changed, 53 insertions, 1 deletions
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp
index f3f9289..f8ef2e7 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+DEFINE_BOOL_CONFIG_OPTION(qmlBasicScriptDump, QML_BASICSCRIPT_DUMP);
+
using namespace QmlJS;
struct ScriptInstruction {
@@ -400,6 +402,8 @@ bool QmlBasicScript::compile(const Expression &expression)
::memcpy((char *)d->data(), bsc.data.constData(), bsc.data.count());
}
+ if (d && qmlBasicScriptDump())
+ dump();
return d != 0;
}
@@ -649,7 +653,7 @@ QVariant QmlBasicScript::run(QmlContext *context, QObject *me)
case ScriptInstruction::FetchRootConstant:
{
- QObject *obj = contextPrivate->defaultObjects.at(0);
+ QObject *obj = contextPrivate->defaultObjects.last();
stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type));
if (obj && instr.constant.notify != 0)
diff --git a/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml b/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml
new file mode 100644
index 0000000..f65e253
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/signalTriggeredBindings.qml
@@ -0,0 +1,20 @@
+import Qt.test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ property real base: 50
+ property alias test1: myObject.test1
+ property alias test2: myObject.test2
+
+ objectProperty: Object {
+ id: myObject
+ property real test1: base
+ property real test2: Math.max(0, base)
+ }
+
+ // Signal with no args
+ onBasicSignal: base = 200
+ // Signal with args
+ onArgumentSignal: base = 400
+}
+
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 5e04f7c..f976e41 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -62,6 +62,7 @@ private slots:
void selfDeletingBinding();
void extendedObjectPropertyLookup();
void scriptErrors();
+ void signalTriggeredBindings();
private:
QmlEngine engine;
@@ -759,6 +760,33 @@ void tst_qmlecmascript::scriptErrors()
QVERIFY(object != 0);
}
+/*
+Test bindings still work when the reeval is triggered from within
+a signal script.
+*/
+void tst_qmlecmascript::signalTriggeredBindings()
+{
+ QmlComponent component(&engine, TEST_FILE("signalTriggeredBindings.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("base").toReal(), 50.);
+ QCOMPARE(object->property("test1").toReal(), 50.);
+ QCOMPARE(object->property("test2").toReal(), 50.);
+
+ object->basicSignal();
+
+ QCOMPARE(object->property("base").toReal(), 200.);
+ QCOMPARE(object->property("test1").toReal(), 200.);
+ QCOMPARE(object->property("test2").toReal(), 200.);
+
+ object->argumentSignal(10, QString(), 10);
+
+ QCOMPARE(object->property("base").toReal(), 400.);
+ QCOMPARE(object->property("test1").toReal(), 400.);
+ QCOMPARE(object->property("test2").toReal(), 400.);
+}
+
QTEST_MAIN(tst_qmlecmascript)
#include "tst_qmlecmascript.moc"