diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-03-27 16:56:08 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-29 00:40:48 +0200 |
commit | 53d5deb5034bf5adb8719723bc66eb3a61638a32 (patch) | |
tree | 011c99abcadf6c4ef723586e25c8f56cd6f3b113 /src/qml/qml/qqmlexpression.cpp | |
parent | e4baefacff3e04ea3b599c5279e883d75d2ad489 (diff) |
Use minimal javascript expression for bound signals
Previously, QQmlBoundSignal used QQmlExpression internally. This
commit adds a new, more optimal QQmlJavaScriptExpression subclass
specifically designed for QQmlBoundSignal, and converts the code
to use it instead of QQmlExpression where appropriate.
Task-number: QTBUG-24460
Change-Id: I2865a119ce840235e27a7722d8052ca61c265f69
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlexpression.cpp')
-rw-r--r-- | src/qml/qml/qqmlexpression.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index d760486605..6e20047cf0 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -351,7 +351,7 @@ void QQmlExpression::setExpression(const QString &expression) } // Must be called with a valid handle scope -v8::Local<v8::Value> QQmlExpressionPrivate::v8value(QObject *secondaryScope, bool *isUndefined) +v8::Local<v8::Value> QQmlExpressionPrivate::v8value(bool *isUndefined) { if (!expressionFunctionValid) { bool ok = true; @@ -369,21 +369,10 @@ v8::Local<v8::Value> QQmlExpressionPrivate::v8value(QObject *secondaryScope, boo expressionFunctionValid = true; } - - if (secondaryScope) { - v8::Local<v8::Value> result; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); - QObject *restoreSecondaryScope = 0; - restoreSecondaryScope = ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope); - result = evaluate(context(), v8function, isUndefined); - ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope); - return result; - } else { - return evaluate(context(), v8function, isUndefined); - } + return evaluate(context(), v8function, isUndefined); } -QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) +QVariant QQmlExpressionPrivate::value(bool *isUndefined) { Q_Q(QQmlExpression); @@ -400,7 +389,7 @@ QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined { v8::HandleScope handle_scope; v8::Context::Scope context_scope(ep->v8engine()->context()); - v8::Local<v8::Value> result = v8value(secondaryScope, isUndefined); + v8::Local<v8::Value> result = v8value(isUndefined); rv = ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >()); } @@ -421,7 +410,7 @@ QVariant QQmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined QVariant QQmlExpression::evaluate(bool *valueIsUndefined) { Q_D(QQmlExpression); - return d->value(0, valueIsUndefined); + return d->value(valueIsUndefined); } /*! |