From 4613955f735837d8007f5558db6a07ec5efb9ab5 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 12 Mar 2010 17:33:06 +1000 Subject: Optimization: Use id notifier for QtScript bindings --- .../qml/qdeclarativecontextscriptclass.cpp | 9 +++++--- src/declarative/qml/qdeclarativeengine_p.h | 5 ++++- src/declarative/qml/qdeclarativeexpression.cpp | 24 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 874eeac..0e5066e 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -252,6 +252,9 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) QScriptValue rv; if (lastPropertyIndex < cp->idValueCount) { rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data()); + + if (ep->captureProperties) + ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(&cp->idValues[lastPropertyIndex].bindings); } else { const QVariant &value = cp->propertyValues.at(lastPropertyIndex); if (value.userType() == qMetaTypeId >()) { @@ -259,10 +262,10 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) } else { rv = ep->scriptValueFromVariant(value); } - } - if (ep->captureProperties) - ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + if (ep->captureProperties) + ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + } return Value(scriptEngine, rv); diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index c73a758..fb8c5e7 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -144,10 +144,13 @@ public: struct CapturedProperty { CapturedProperty(QObject *o, int c, int n) - : object(o), coreIndex(c), notifyIndex(n) {} + : object(o), coreIndex(c), notifier(0), notifyIndex(n) {} + CapturedProperty(QDeclarativeNotifier *n) + : object(0), coreIndex(-1), notifier(n), notifyIndex(-1) {} QObject *object; int coreIndex; + QDeclarativeNotifier *notifier; int notifyIndex; }; bool captureProperties; diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 5ff22f7..f3299ba 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -656,7 +656,29 @@ void QDeclarativeExpressionPrivate::updateGuards(const QPODVectorguardList[jj].isConnected(property.notifier)) + existing = true; + + if (existing) { + // duplicate + guard.disconnect(); + } else { + guard.connect(property.notifier); + } + } + + + } else if (property.notifyIndex != -1) { if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) { // Nothing to do -- cgit v0.12