aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-12-05 14:31:50 +0100
committerLars Knoll <lars.knoll@qt.io>2016-12-09 14:02:26 +0000
commitb45ebc6f456cf26912b14bb3809d14d696d9809a (patch)
tree43be87e1b24071ef85b0564283bb914416b0a00c
parenta11be5881a38933d36facfbc4f8baa1becd22546 (diff)
Avoid passing a FunctionObject to QQmlBinding::create()
Like this we can remove the QQmlBinding::create() overload that takes a FunctionObject. Change-Id: Ib6c37395ded325e68cf0fbf3afd08fb6dd6efa3b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp3
-rw-r--r--src/qml/qml/qqmlbinding.cpp19
-rw-r--r--src/qml/qml/qqmlbinding_p.h3
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp2
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp3
6 files changed, 10 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 888983d7c7..5f66b56a42 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -392,7 +392,8 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f);
- newBinding = QQmlBinding::create(property, f, object, callingQmlContext);
+ QV4::ScopedContext ctx(scope, bindingFunction->scope());
+ newBinding = QQmlBinding::create(property, bindingFunction->function(), object, callingQmlContext, ctx);
newBinding->setSourceLocation(bindingFunction->currentLocation());
newBinding->setTarget(object, *property, nullptr);
}
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index f85680f080..ab6cb60c7b 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -110,21 +110,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString
return b;
}
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::FunctionObject *function, QObject *obj, QQmlContextData *ctxt)
-{
- QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
-
- b->setNotifyOnValueChanged(true);
- b->QQmlJavaScriptExpression::setContext(ctxt);
- b->setScopeObject(obj);
-
- b->setFunctionObject(function);
-
- return b;
-}
-
QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function *function,
- QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext)
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
@@ -132,8 +119,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
- Q_ASSERT(sharedContext);
- b->setupFunction(sharedContext, function);
+ Q_ASSERT(scope);
+ b->setupFunction(scope, function);
return b;
}
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index 889f2ad0af..af95bbb5db 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -75,9 +75,8 @@ public:
static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *);
static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *,
const QString &url = QString(), quint16 lineNumber = 0);
- static QQmlBinding *create(const QQmlPropertyData *, const QV4::FunctionObject *function, QObject *, QQmlContextData *);
static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function,
- QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext);
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope);
~QQmlBinding();
void setTarget(const QQmlProperty &);
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 6383b631cd..c521e0793a 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -466,7 +466,7 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o)
m_compilationUnit = m_v4Function->compilationUnit;
}
-void QQmlJavaScriptExpression::setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f)
+void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f)
{
if (!qmlContext || !f)
return;
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 4d88c987b8..8cbaf891a4 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -160,7 +160,7 @@ protected:
}
void setFunctionObject(const QV4::FunctionObject *o);
- void setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f);
+ void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
private:
friend class QQmlContextData;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 4ce7f67760..bbef62186a 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -454,7 +454,8 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f);
- QQmlBinding *newBinding = QQmlBinding::create(&cacheData, f, reference->d()->object, context);
+ QV4::ScopedContext ctx(scope, bindingFunction->scope());
+ QQmlBinding *newBinding = QQmlBinding::create(&cacheData, bindingFunction->function(), reference->d()->object, context, ctx);
newBinding->setSourceLocation(bindingFunction->currentLocation());
newBinding->setTarget(reference->d()->object, cacheData, pd);
QQmlPropertyPrivate::setBinding(newBinding);