From 1eee98f1c1c59f8c45387684e269629713958bd4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 14:23:04 +0100 Subject: Limit access to m_function to QQmlJavaScriptExpression Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/qml/qml/qqmljavascriptexpression.cpp') 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::Value *v = m_function.valueRef(); + if (!v) + return 0; + QV4::FunctionObject *f = v->as(); if (f && f->isBinding()) return static_cast(f)->d()->originalFunction->function; return f ? f->function() : 0; @@ -430,7 +433,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QV4::Scoped 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()); } -- cgit v1.2.3