diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-12-02 14:23:04 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-12-09 14:01:42 +0000 |
commit | 1eee98f1c1c59f8c45387684e269629713958bd4 (patch) | |
tree | 786e909d5427e07c08d9a7263d005723cf95c737 /src/qml/qml/qqmljavascriptexpression.cpp | |
parent | f1dca03794f8db353655d44e742a2960f1f69070 (diff) |
Limit access to m_function to QQmlJavaScriptExpression
Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression.cpp')
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index cb36758f74..9616a088ae 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -160,7 +160,10 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context) QV4::Function *QQmlJavaScriptExpression::function() const { - QV4::FunctionObject *f = m_function.valueRef()->as<QV4::FunctionObject>(); + QV4::Value *v = m_function.valueRef(); + if (!v) + return 0; + QV4::FunctionObject *f = v->as<QV4::FunctionObject>(); if (f && f->isBinding()) return static_cast<QV4::QQmlBindingFunction *>(f)->d()->originalFunction->function; return f ? f->function() : 0; @@ -430,7 +433,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope)); QV4::Script script(v4, qmlContext, code, filename, line); - QV4::ScopedValue result(scope); + QV4::ScopedFunctionObject result(scope); script.parse(); if (!v4->hasException) result = script.qmlBinding(); @@ -446,7 +449,13 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * ep->warning(error); result = QV4::Encode::undefined(); } - m_function.set(v4, result); + setFunctionObject(result); +} + +void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) +{ + if (o) + m_function.set(o->engine(), o->d()); } |