diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-17 11:37:17 +1000 |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-17 11:37:17 +1000 |
commit | 69a17a912a41458a2b4a20bdbda1717920275250 (patch) | |
tree | f0eb0cdb210765ddb954539a0fbe520640eae2a1 /src/declarative/qml/qdeclarativebinding.cpp | |
parent | 9c5e112e12f09ad5c8356d6815f9b23102e99bfd (diff) |
Evaluate all shared bindings together using a shared context
The vast majority of bindings are capable of being shared (that is, don't
introduce closures themselves) and consequently this improves the
performance of almost every app.
Diffstat (limited to 'src/declarative/qml/qdeclarativebinding.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativebinding.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index d1fdec5a63..fee55545cf 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -226,15 +226,6 @@ QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate() { } -QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, QObject *obj, - QDeclarativeContextData *ctxt, const QString &url, int lineNumber, - QObject *parent) -: QDeclarativeExpression(ctxt, data, rc, obj, url, lineNumber, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - QDeclarativeBinding * QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeContext *ctxt, const QString &url, int lineNumber, QObject *parent) @@ -251,7 +242,7 @@ QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeCont typeData = engine->typeLoader.get(ctxtdata->url); cdata = typeData->compiledData(); } - QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding((void*)cdata->datas.at(id).constData(), cdata, obj, ctxtdata, url, lineNumber, parent) : 0; + QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, parent) : 0; if (typeData) typeData->release(); return rv; @@ -273,6 +264,15 @@ QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDecl setNotifyOnValueChanged(true); } +QDeclarativeBinding::QDeclarativeBinding(const QString &str, bool isRewritten, QObject *obj, + QDeclarativeContextData *ctxt, + const QString &url, int lineNumber, QObject *parent) +: QDeclarativeExpression(ctxt, obj, str, isRewritten, url, lineNumber, *new QDeclarativeBindingPrivate) +{ + setParent(parent); + setNotifyOnValueChanged(true); +} + /*! \internal @@ -413,19 +413,17 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } else { QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine); - ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. + ep->referenceScarceResources(); bool isUndefined = false; - QVariant value; v8::HandleScope handle_scope; v8::Context::Scope scope(ep->v8engine.context()); v8::Local<v8::Value> result = d->v8value(0, &isUndefined); bool needsErrorData = false; - if (!watcher.wasDeleted() && !d->error.isValid()) { + if (!watcher.wasDeleted() && !d->error.isValid()) needsErrorData = !d->writeBindingResult(d, d->property, result, isUndefined, flags); - } if (!watcher.wasDeleted()) { @@ -453,10 +451,15 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) if (!watcher.wasDeleted()) d->updating = false; } else { - qmlInfo(d->property.object()) << tr("Binding loop detected for property \"%1\"").arg(d->property.name()); + QDeclarativeBindingPrivate::printBindingLoopError(d->property); } } +void QDeclarativeBindingPrivate::printBindingLoopError(QDeclarativeProperty &prop) +{ + qmlInfo(prop.object()) << QDeclarativeBinding::tr("Binding loop detected for property \"%1\"").arg(prop.name()); +} + void QDeclarativeBindingPrivate::emitValueChanged() { Q_Q(QDeclarativeBinding); |