diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-05-14 13:29:47 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-15 09:16:41 +0200 |
commit | e1c26307c25173d4f44592dcd01d22eafda76f23 (patch) | |
tree | 48876990cdc392741c4bb81c9a64b263ed93e343 | |
parent | e0eec47cac3f9f06613011dd70db74b7cd7d61ef (diff) |
Revert "Allow function assignment to cause binding for non-var props"
This reverts commit 92b1f9981d225ecee28da1f0a88fb3046000cb5e.
Conflicts:
src/qml/qml/v8/qv8qobjectwrapper.cpp
Also remove XPASS tests from qjsonbinding
Change-Id: Ibc9da28d5f0bdffbf62e7e20f12bb55ff36ae271
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 |
3 files changed, 6 insertions, 31 deletions
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index fde7f66abc..5c0b592479 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -589,31 +589,11 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert if (value->IsFunction()) { if (value->ToObject()->GetHiddenValue(engine->bindingFlagKey()).IsEmpty()) { if (!property->isVMEProperty()) { - // XXX TODO: uncomment the following lines // assigning a JS function to a non-var-property is not allowed. - //QString error = QLatin1String("Cannot assign JavaScript function to ") + - // QLatin1String(QMetaType::typeName(property->propType)); - //v8::ThrowException(v8::Exception::Error(engine->toString(error))); - //return; - // XXX TODO: remove the following transition behaviour - // Temporarily allow assignment of functions to non-var properties - // to mean binding assignment (as per old behaviour). - QQmlContextData *context = engine->callingContext(); - v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(value); - - v8::Local<v8::StackTrace> trace = - v8::StackTrace::CurrentStackTrace(1, (v8::StackTrace::StackTraceOptions)(v8::StackTrace::kLineNumber | - v8::StackTrace::kScriptName)); - v8::Local<v8::StackFrame> frame = trace->GetFrame(0); - int lineNumber = frame->GetLineNumber(); - int columnNumber = frame->GetColumn(); - QString url = engine->toString(frame->GetScriptName()); - - newBinding = new QQmlBinding(&function, object, context, url, lineNumber, columnNumber); - newBinding->setTarget(object, *property, context); - newBinding->setEvaluateFlags(newBinding->evaluateFlags() | - QQmlBinding::RequiresThisObject); - qWarning("WARNING: function assignment is DEPRECATED and will be removed! Wrap RHS in Qt.binding(): %s:%d", qPrintable(engine->toString(frame->GetScriptName())), frame->GetLineNumber()); + QString error = QLatin1String("Cannot assign JavaScript function to ") + + QLatin1String(QMetaType::typeName(property->propType)); + v8::ThrowException(v8::Exception::Error(engine->toString(error))); + return; } } else { // binding assignment. diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index 09b256288a..2900b5cfe3 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -412,9 +412,6 @@ void tst_qjsonbinding::writeProperty_incompatibleType() QJSValue ret = eng.evaluate(QString::fromLatin1("obj.%0 = %1") .arg(property).arg(expression)); - QEXPECT_FAIL("value=function", "See 'XXX TODO: uncomment the following lines' in qv8qobjectwrapper.cpp", Abort); - QEXPECT_FAIL("object=function", "See 'XXX TODO: uncomment the following lines' in qv8qobjectwrapper.cpp", Abort); - QEXPECT_FAIL("array=function", "See 'XXX TODO: uncomment the following lines' in qv8qobjectwrapper.cpp", Abort); QVERIFY(ret.isError()); QVERIFY(ret.toString().contains("Cannot assign")); } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 40bff34ae2..b910ec7b83 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -5568,15 +5568,13 @@ void tst_qqmlecmascript::functionAssignment_afterBinding() QQmlComponent component(&engine, testFileUrl("functionAssignment.3.qml")); QString url = component.url().toString(); - //QString w1 = url + ":16: Error: Cannot assign JavaScript function to int"; // for now, function assignment = binding assignment - QString w1 = QLatin1String("WARNING: function assignment is DEPRECATED and will be removed! Wrap RHS in Qt.binding(): ") + url + QLatin1String(":16"); + QString w1 = url + ":16: Error: Cannot assign JavaScript function to int"; QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData()); QObject *o = component.create(); QVERIFY(o != 0); QCOMPARE(o->property("t1"), QVariant::fromValue<int>(4)); // should have bound - //QCOMPARE(o->property("t2"), QVariant::fromValue<int>(2)); // should not have changed - QCOMPARE(o->property("t2"), QVariant::fromValue<int>(4)); // for now, function assignment = binding assignment + QCOMPARE(o->property("t2"), QVariant::fromValue<int>(2)); // should not have changed delete o; } |