summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-22 08:16:47 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-22 08:16:47 (GMT)
commitba602c39e2ab7c16dcb212c935dbacdf053c6623 (patch)
treeafefdb2249373860a370fb6b92800787d9842da8
parent95e370e53e24cf4210bdea07022a7c4d94cd8854 (diff)
downloadQt-ba602c39e2ab7c16dcb212c935dbacdf053c6623.zip
Qt-ba602c39e2ab7c16dcb212c935dbacdf053c6623.tar.gz
Qt-ba602c39e2ab7c16dcb212c935dbacdf053c6623.tar.bz2
Fix test failures.
Also add a test for script errors within signal handlers.
-rw-r--r--src/declarative/qml/qmlbinding.cpp6
-rw-r--r--src/declarative/qml/qmlexpression.cpp6
-rw-r--r--src/declarative/qml/qmlvme.cpp6
-rw-r--r--tests/auto/declarative/qmlecmascript/data/scriptErrors.qml6
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp6
5 files changed, 22 insertions, 8 deletions
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
index 2b4e723..65ff789 100644
--- a/src/declarative/qml/qmlbinding.cpp
+++ b/src/declarative/qml/qmlbinding.cpp
@@ -128,8 +128,10 @@ void QmlBinding::update(QmlMetaProperty::WriteFlags flags)
idx, a);
} else {
- QVariant value = this->value();
- if (data->property.object() && !data->property.write(value, flags)) {
+ bool undefined = false;
+ QVariant value = this->value(&undefined);
+
+ if (!undefined && data->property.object() && !data->property.write(value, flags)) {
QString fileName = data->fileName;
int line = data->line;
if (fileName.isEmpty()) fileName = QLatin1String("<Unknown File>");
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
index d2bf4a8..7f01f0e 100644
--- a/src/declarative/qml/qmlexpression.cpp
+++ b/src/declarative/qml/qmlexpression.cpp
@@ -319,10 +319,12 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd
QScriptValue svalue = data->expressionFunction.call();
if (isUndefined)
- *isUndefined = svalue.isUndefined();
+ *isUndefined = svalue.isUndefined() || scriptEngine->hasUncaughtException();
- if (scriptEngine->hasUncaughtException())
+ if (scriptEngine->hasUncaughtException()) {
printException(scriptEngine);
+ return QVariant();
+ }
if (secondaryScope)
ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount);
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 7f673a2..fc19ebd2 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -540,7 +540,11 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt,
QMetaMethod signal =
target->metaObject()->method(instr.storeSignal.signalIndex);
- (void *)new QmlBoundSignal(ctxt, primitives.at(instr.storeSignal.value), target, signal, target);
+ QmlBoundSignal *bs = new QmlBoundSignal(target, signal, target);
+ QmlExpression *expr =
+ new QmlExpression(ctxt, primitives.at(instr.storeSignal.value), target);
+ expr->setSourceLocation(comp->url, instr.line);
+ bs->setExpression(expr);
}
break;
diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
index 3fb8ff7..d39b312 100644
--- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml
@@ -1,10 +1,12 @@
-import Qt 4.6
+import Qt.test 1.0
-Object {
+MyQmlObject {
Script { source: "scriptErrors.js" }
Script { function getValue() { a = 10; return 0; } }
property int x: a.value
property int y: getValue();
+
+ onBasicSignal: { print(a.value); }
}
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index 34b49e6..a7a2ef6 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -760,12 +760,16 @@ void tst_qmlecmascript::scriptErrors()
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
QString warning2 = url + ":7: TypeError: Result of expression 'a' [undefined] is not an object.";
QString warning3 = url + ":5: Error: Invalid write to global property \"a\"";
+ QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QObject *object = component.create();
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ emit object->basicSignal();
}
/*