aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmltypecompiler.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-06 09:35:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-07 12:44:08 +0100
commit50ce88a53107f97664d928719c1877b8077e9a2e (patch)
treea43fdc574cf5028517443514b5d56be221b86dd1 /src/qml/compiler/qqmltypecompiler.cpp
parentd5a96399cec189251d8ee3e82493aceec112fbd8 (diff)
[new compiler] Fix parser status and created bindings allocation
Pre-calculate the amount of space we need for binding and parser status callbacks at compile time and therefore use a much simpler data structure (vector) to store the points to the bindings and callbacks. They need to be stored because during object construction and binding enabling phase, it may happen that they get destroyed and thus their m_mePtr pointing into the array gets deleted. The contiguous vector will also make it possible to interrupt the completion phase. Change-Id: Ic7c985bb8325ab355112e30e9d33d6ae4e7476d1 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmltypecompiler.cpp')
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 4466b430fe..dae57fe6f4 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -244,6 +244,27 @@ bool QQmlTypeCompiler::compile()
if (!validator.validate())
return false;
+ // Collect some data for instantiation later.
+ int bindingCount = 0;
+ int parserStatusCount = 0;
+ for (quint32 i = 0; i < qmlUnit->nObjects; ++i) {
+ const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i);
+ bindingCount += obj->nBindings;
+ if (QQmlCompiledData::TypeReference *typeRef = compiledData->resolvedTypes.value(obj->inheritedTypeNameIndex)) {
+ if (QQmlType *qmlType = typeRef->type) {
+ if (qmlType->parserStatusCast() != -1)
+ ++parserStatusCount;
+ }
+ if (typeRef->component) {
+ bindingCount += typeRef->component->totalBindingsCount;
+ parserStatusCount += typeRef->component->totalParserStatusCount;
+ }
+ }
+ }
+
+ compiledData->totalBindingsCount = bindingCount;
+ compiledData->totalParserStatusCount = parserStatusCount;
+
return errors.isEmpty();
}