aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-09-16 14:47:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 14:26:30 +0200
commitd847bf07a2659a9b1bf022565eca5455f918b50c (patch)
tree80791f07f864e586f79688cc5ae63453f8729a4e
parent21a7409446ba43066c7c8209edc37cf5b9a7bb94 (diff)
[new compiler] Fix timing of binding enabling
Enabling bindings right before emitting Component.onComplete Change-Id: I4cc330f5e59b326368c617f16a7d4fd51b6c50db Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp54
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h5
2 files changed, 37 insertions, 22 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 9ce2c26882..c85f0fa5d4 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -878,10 +878,8 @@ void QmlObjectCreator::setPropertyValue(QQmlPropertyData *property, const QV4::C
}
}
-QVector<QQmlAbstractBinding*> QmlObjectCreator::setupBindings(QV4::ExecutionContext *qmlContext)
+void QmlObjectCreator::setupBindings(QV4::ExecutionContext *qmlContext)
{
- QVector<QQmlAbstractBinding*> createdDynamicBindings(_compiledObject->nBindings, 0);
-
const QV4::CompiledData::Binding *binding = _compiledObject->bindingTable();
for (quint32 i = 0; i < _compiledObject->nBindings; ++i, ++binding) {
QString name = stringAt(binding->propertyNameIndex);
@@ -953,8 +951,8 @@ QVector<QQmlAbstractBinding*> QmlObjectCreator::setupBindings(QV4::ExecutionCont
qmlBinding->setTarget(_qobject, *property, context);
qmlBinding->addToObject();
- createdDynamicBindings[i] = qmlBinding;
- qmlBinding->m_mePtr = &createdDynamicBindings[i];
+ _createdBindings[i] = qmlBinding;
+ qmlBinding->m_mePtr = &_createdBindings[i];
}
continue;
}
@@ -964,8 +962,6 @@ QVector<QQmlAbstractBinding*> QmlObjectCreator::setupBindings(QV4::ExecutionCont
if (!errors.isEmpty())
break;
}
-
- return createdDynamicBindings;
}
void QmlObjectCreator::setupFunctions(QV4::ExecutionContext *qmlContext)
@@ -1018,6 +1014,29 @@ QObject *QmlObjectCreator::create(int index, QObject *parent)
void QmlObjectCreator::finalize()
{
{
+ QQmlTrace trace("VME Binding Enable");
+ trace.event("begin binding eval");
+
+ Q_ASSERT(allCreatedBindings.isDetached());
+
+ for (QLinkedList<QVector<QQmlAbstractBinding*> >::Iterator it = allCreatedBindings.begin(), end = allCreatedBindings.end();
+ it != end; ++it) {
+ const QVector<QQmlAbstractBinding *> &bindings = *it;
+ for (int i = 0; i < bindings.count(); ++i) {
+ QQmlAbstractBinding *b = bindings.at(i);
+ if (!b)
+ continue;
+ b->m_mePtr = 0;
+ QQmlData *data = QQmlData::get(b->object());
+ Q_ASSERT(data);
+ data->clearPendingBindingBit(b->propertyIndex());
+ b->setEnabled(true, QQmlPropertyPrivate::BypassInterceptor |
+ QQmlPropertyPrivate::DontRemoveBinding);
+ }
+ }
+ }
+
+ {
QQmlTrace trace("VME Component.onCompleted Callbacks");
while (componentAttached) {
QQmlComponentAttached *a = componentAttached;
@@ -1063,6 +1082,9 @@ void QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi
qSwap(_vmeMetaObject, vmeMetaObject);
+ QVector<QQmlAbstractBinding*> createdBindings(_compiledObject->nBindings, 0);
+ qSwap(_createdBindings, createdBindings);
+
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope valueScope(v4);
QV4::ScopedValue scopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _qobject));
@@ -1070,27 +1092,17 @@ void QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi
QV4::ScopedValue qmlScopeFunction(valueScope, QV4::Value::fromObject(qmlBindingWrapper));
QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context();
- QVector<QQmlAbstractBinding*> dynamicBindings = setupBindings(qmlContext);
+ setupBindings(qmlContext);
setupFunctions(qmlContext);
- // ### do this later when requested
- for (int i = 0; i < dynamicBindings.count(); ++i) {
- QQmlAbstractBinding *b = dynamicBindings.at(i);
- if (!b)
- continue;
- b->m_mePtr = 0;
- QQmlData *data = QQmlData::get(b->object());
- Q_ASSERT(data);
- data->clearPendingBindingBit(b->propertyIndex());
- b->setEnabled(true, QQmlPropertyPrivate::BypassInterceptor |
- QQmlPropertyPrivate::DontRemoveBinding);
- }
-
+ qSwap(_createdBindings, createdBindings);
qSwap(_vmeMetaObject, vmeMetaObject);
qSwap(_propertyCache, cache);
qSwap(_ddata, declarativeData);
qSwap(_compiledObject, obj);
qSwap(_qobject, instance);
+
+ allCreatedBindings.append(_createdBindings);
}
void QmlObjectCreator::recordError(const QV4::CompiledData::Location &location, const QString &description)
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 3bfa006a6d..c247fe22f6 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -45,6 +45,7 @@
#include <private/qqmltypenamecache_p.h>
#include <private/qv4compileddata_p.h>
#include <private/qqmlcompiler_p.h>
+#include <QLinkedList>
QT_BEGIN_NAMESPACE
@@ -95,7 +96,7 @@ public:
private:
void populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache);
- QVector<QQmlAbstractBinding *> setupBindings(QV4::ExecutionContext *qmlContext);
+ void setupBindings(QV4::ExecutionContext *qmlContext);
void setPropertyValue(QQmlPropertyData *property, const QV4::CompiledData::Binding *binding);
void setupFunctions(QV4::ExecutionContext *qmlContext);
@@ -111,12 +112,14 @@ private:
const QList<QQmlPropertyCache *> propertyCaches;
const QList<QByteArray> vmeMetaObjectData;
const QHash<int, int> &objectIndexToId;
+ QLinkedList<QVector<QQmlAbstractBinding*> > allCreatedBindings;
QObject *_qobject;
const QV4::CompiledData::Object *_compiledObject;
QQmlData *_ddata;
QQmlRefPointer<QQmlPropertyCache> _propertyCache;
QQmlVMEMetaObject *_vmeMetaObject;
+ QVector<QQmlAbstractBinding*> _createdBindings;
};
QT_END_NAMESPACE