diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2012-02-14 12:13:51 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-20 14:48:06 +0100 |
commit | 549916563e693fc2835d1fa0d5baa3a77b027284 (patch) | |
tree | 200cfdb6f0447cc4eb08840642c04c6324ef8b58 /src/declarative/qml/v8 | |
parent | d88578e58b8e85038568355fcbe2d5127ed208f4 (diff) |
Reduce the size of QDeclarative*Expression
Reduces the size of QDeclarativeAbstractExpression and
QDeclarativeJavaScriptExpression.
Change-Id: I39386e5a45f8bd12bfb2d80b47dfec37f2f05479
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8')
-rw-r--r-- | src/declarative/qml/v8/qv8bindings.cpp | 35 | ||||
-rw-r--r-- | src/declarative/qml/v8/qv8bindings_p.h | 5 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/declarative/qml/v8/qv8bindings.cpp b/src/declarative/qml/v8/qv8bindings.cpp index 39203d35af..cd86e6a13f 100644 --- a/src/declarative/qml/v8/qv8bindings.cpp +++ b/src/declarative/qml/v8/qv8bindings.cpp @@ -67,6 +67,12 @@ void QV8Bindings::Binding::setEnabled(bool e, QDeclarativePropertyPrivate::Write } } +void QV8Bindings::refresh() +{ + for (int ii = 0; ii < bindingsCount; ++ii) + bindings[ii].refresh(); +} + void QV8Bindings::Binding::refresh() { update(); @@ -84,7 +90,7 @@ void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags) QDeclarativeBindingProfiler prof(parent->url.toString(), line, column); - QDeclarativeContextData *context = QDeclarativeAbstractExpression::context(); + QDeclarativeContextData *context = parent->context(); if (!context || !context->isValid()) return; @@ -94,19 +100,21 @@ void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags) bool isUndefined = false; - QDeleteWatcher watcher(this); + DeleteWatcher watcher(this); ep->referenceScarceResources(); v8::HandleScope handle_scope; v8::Context::Scope scope(ep->v8engine()->context()); - v8::Local<v8::Value> result = evaluate(v8::Handle<v8::Function>::Cast(parent->functions->Get(index)), - &isUndefined); + v8::Local<v8::Value> result = + evaluate(context, v8::Handle<v8::Function>::Cast(parent->functions->Get(index)), + &isUndefined); trace.event("writing V8 result"); bool needsErrorData = false; - if (!watcher.wasDeleted() && !error.isValid()) { + if (!watcher.wasDeleted() && !hasError()) { typedef QDeclarativePropertyPrivate PP; - needsErrorData = !PP::writeBinding(object, property, this, result, isUndefined, flags); + needsErrorData = !PP::writeBinding(object, property, context, this, result, + isUndefined, flags); } if (!watcher.wasDeleted()) { @@ -115,15 +123,15 @@ void QV8Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags) QUrl url = QUrl(parent->url); if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>")); - error.setUrl(url); - error.setLine(line); - error.setColumn(-1); + delayedError()->error.setUrl(url); + delayedError()->error.setLine(line); + delayedError()->error.setColumn(-1); } - if (error.isValid()) { - if (!addError(ep)) ep->warning(error); + if (hasError()) { + if (!delayedError()->addError(ep)) ep->warning(delayedError()->error); } else { - removeError(); + clearError(); } updating = false; @@ -152,7 +160,7 @@ void QV8Bindings::Binding::destroy() enabled = false; removeFromObject(); clear(); - removeError(); + clearError(); parent->release(); } @@ -230,7 +238,6 @@ QDeclarativeAbstractBinding *QV8Bindings::configBinding(int index, QObject *targ rv->index = index; rv->object = target; rv->property = p; - rv->setContext(context()); rv->setScopeObject(scope); rv->setUseSharedContext(true); rv->setNotifyOnValueChanged(true); diff --git a/src/declarative/qml/v8/qv8bindings_p.h b/src/declarative/qml/v8/qv8bindings_p.h index 8eaf4ff290..83bbed5b5a 100644 --- a/src/declarative/qml/v8/qv8bindings_p.h +++ b/src/declarative/qml/v8/qv8bindings_p.h @@ -77,6 +77,9 @@ public: const QDeclarativePropertyData &prop, int line, int column); + // Inherited from QDeclarativeAbstractExpression + virtual void refresh(); + private: Q_DISABLE_COPY(QV8Bindings) @@ -85,6 +88,7 @@ private: Binding(); void update() { QDeclarativeAbstractBinding::update(); } + void refresh(); // Inherited from QDeclarativeJavaScriptExpression inline virtual QString expressionIdentifier(); @@ -94,7 +98,6 @@ private: virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags); virtual void update(QDeclarativePropertyPrivate::WriteFlags flags); virtual void destroy(); - virtual void refresh(); int index:30; bool enabled:1; |