diff options
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 1 |
8 files changed, 14 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 0cdf6b5d7c..f70ddb04d4 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -50,6 +50,7 @@ #include <private/qqmlengine_p.h> #include <qv4codegen_p.h> #include "private/qlocale_tools_p.h" +#include "private/qqmlbuiltinfunctions_p.h" #include <QtCore/qmath.h> #include <QtCore/QDebug> @@ -202,6 +203,11 @@ Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *sco return scope->d()->engine->memoryManager->alloc<SimpleScriptFunction>(scope, function, createProto); } +bool FunctionObject::isBinding() const +{ + return d()->internalClass->vtable == QQmlBindingFunction::staticVTable(); +} + DEFINE_OBJECT_VTABLE(FunctionCtor); Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope) diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 7406e9b0ff..d3053ce283 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -143,7 +143,7 @@ struct Q_QML_EXPORT FunctionObject: Object { bool needsActivation() const { return d()->needsActivation; } bool strictMode() const { return d()->function ? d()->function->isStrict() : false; } - bool bindingKeyFlag() const { return d()->bindingKeyFlag; } + bool isBinding() const; static void markObjects(Heap::Base *that, ExecutionEngine *e); }; diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 46a458b1f5..149bf2434c 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -458,7 +458,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro QV4::Scope scope(ctx); QV4::ScopedFunctionObject f(scope, value); if (f) { - if (!f->bindingKeyFlag()) { + if (!f->isBinding()) { if (!property->isVarProperty() && property->propType != qMetaTypeId<QJSValue>()) { // assigning a JS function to a non var or QJSValue property or is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to "); diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 01a1542b07..6a67719464 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -63,7 +63,7 @@ struct Q_QML_EXPORT Base { uchar extensible : 1; // used by Object uchar needsActivation : 1; // used by FunctionObject uchar _strictMode : 1; // used by FunctionObject - uchar bindingKeyFlag : 1; + uchar _bindingKeyFlag : 1; uchar hasAccessorProperty : 1; uchar _unused : 1; mutable uchar subtype; diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 3eb3870b96..3de29551ff 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -169,7 +169,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) QV4::Scope scope(ep->v4engine()); QV4::ScopedFunctionObject f(scope, v4function.value()); Q_ASSERT(f); - if (f->bindingKeyFlag()) { + if (f->isBinding()) { Q_ASSERT(f->as<QV4::QQmlBindingFunction>()); QQmlSourceLocation loc = static_cast<QV4::Heap::QQmlBindingFunction *>(f->d())->bindingLocation; url = loc.sourceFile; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index b22943ebff..a4c46a1705 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1526,7 +1526,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, return false; } else if (isVarProperty) { QV4::FunctionObject *f = result->asFunctionObject(); - if (f && f->bindingKeyFlag()) { + if (f && f->isBinding()) { // we explicitly disallow this case to avoid confusion. Users can still store one // in an array in a var property if they need to, but the common case is user error. expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); @@ -1544,7 +1544,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, writeValueProperty(object, core, QVariant(), context, flags); } else if (type == qMetaTypeId<QJSValue>()) { QV4::FunctionObject *f = result->asFunctionObject(); - if (f && f->bindingKeyFlag()) { + if (f && f->isBinding()) { expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); expression->delayedError()->setErrorObject(object); return false; @@ -1562,7 +1562,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, expression->delayedError()->setErrorObject(object); return false; } else if (QV4::FunctionObject *f = result->asFunctionObject()) { - if (f->bindingKeyFlag()) + if (f->isBinding()) expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); else expression->delayedError()->setErrorDescription(QLatin1String("Unable to assign a function to a property of any type other than var.")); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index fb52fba1fa..b72b89c11d 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -364,7 +364,7 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value) QV4::ScopedFunctionObject f(scope, value); if (reference && f) { - if (!f->bindingKeyFlag()) { + if (!f->isBinding()) { // assigning a JS function to a non-var-property is not allowed. QString error = QStringLiteral("Cannot assign JavaScript function to value-type property"); ScopedString e(scope, v4->newString(error)); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index eb4e7c4d23..6cb7990dd6 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1149,7 +1149,6 @@ Heap::QQmlBindingFunction::QQmlBindingFunction(QV4::FunctionObject *originalFunc , originalFunction(originalFunction->d()) { setVTable(QV4::QQmlBindingFunction::staticVTable()); - bindingKeyFlag = true; } void QQmlBindingFunction::initBindingLocation() |