aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-27 14:30:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 15:22:58 +0100
commit186f8e2f76dc6995d14e6632d9b9d704198feda2 (patch)
tree6213cee17297940c46c9ff0a52160a42152d0b4a /src/qml/qml/qqmlobjectcreator.cpp
parentb02bed1caae6966925b9efb04e1db79c3e9ef687 (diff)
[new compiler] Fix some qqmlincubator tests
We need to track the objects created and pass them over to the VME guard used in the incubator. The incremental build nature of the incubator requires that to avoid crashes. For nested incubators we need to set the activeVMEData field in the root QQmlContext, to allow child incubators to locate the parent. Lastly we need can emulate most of the VME behavior in terms of build states when running with QQmlInstantiationInterrupt by presenting four build steps: The initial state, two build steps, a finalization step and the state when we're done. Change-Id: I16cd7f71744decb9d4735ec77e9d944fad18e88d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index e965cab179..8a28fa1211 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -80,11 +80,13 @@ static void removeBindingOnProperty(QObject *o, int index)
if (binding) binding->destroy();
}
-QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlContextData *creationContext)
- : compiledData(compiledData)
+QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlContextData *creationContext, void *activeVMEDataForRootContext)
+ : phase(Startup)
+ , compiledData(compiledData)
, resolvedTypes(compiledData->resolvedTypes)
, propertyCaches(compiledData->propertyCaches)
, vmeMetaObjectData(compiledData->datas)
+ , activeVMEDataForRootContext(activeVMEDataForRootContext)
{
init(parentContext);
@@ -93,15 +95,18 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile
sharedState->componentAttached = 0;
sharedState->allCreatedBindings.allocate(compiledData->totalBindingsCount);
sharedState->allParserStatusCallbacks.allocate(compiledData->totalParserStatusCount);
+ sharedState->allCreatedObjects.allocate(compiledData->totalObjectCount);
sharedState->creationContext = creationContext;
sharedState->rootContext = 0;
}
QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompiledData *compiledData, QQmlObjectCreatorSharedState *inheritedSharedState)
- : compiledData(compiledData)
+ : phase(Startup)
+ , compiledData(compiledData)
, resolvedTypes(compiledData->resolvedTypes)
, propertyCaches(compiledData->propertyCaches)
, vmeMetaObjectData(compiledData->datas)
+ , activeVMEDataForRootContext(0)
{
init(parentContext);
@@ -148,8 +153,15 @@ QQmlObjectCreator::~QQmlObjectCreator()
}
}
-QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent)
+QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlInstantiationInterrupt *interrupt)
{
+ if (phase == CreatingObjectsPhase2) {
+ phase = ObjectsCreated;
+ return context->contextObject;
+ }
+ Q_ASSERT(phase == Startup);
+ phase = CreatingObjects;
+
int objectToCreate;
if (subComponentIndex == -1) {
@@ -171,6 +183,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent)
if (!sharedState->rootContext) {
sharedState->rootContext = context;
+ sharedState->rootContext->activeVMEData = activeVMEDataForRootContext;
sharedState->rootContext->isRootObjectInCreation = true;
}
@@ -211,6 +224,13 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->contextObject = instance;
}
+ phase = CreatingObjectsPhase2;
+
+ if (interrupt && interrupt->shouldInterrupt())
+ return 0;
+
+ phase = ObjectsCreated;
+
return instance;
}
@@ -990,6 +1010,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent)
ddata->rootObjectInCreation = true;
sharedState->rootContext->isRootObjectInCreation = false;
}
+
+ sharedState->allCreatedObjects.push(instance);
} else {
Q_ASSERT(typeRef->component);
if (typeRef->component->qmlUnit->isSingleton())
@@ -1078,6 +1100,9 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent)
QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt)
{
+ Q_ASSERT(phase == ObjectsCreated || phase == Finalizing);
+ phase = Finalizing;
+
QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher(sharedState.data());
ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine));
@@ -1148,9 +1173,23 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru
}
}
+ phase = Done;
+
return sharedState->rootContext;
}
+void QQmlObjectCreator::clear()
+{
+ if (phase == Done || phase == Finalizing || phase == Startup)
+ return;
+ Q_ASSERT(phase != Startup);
+
+ while (!sharedState->allCreatedObjects.isEmpty())
+ delete sharedState->allCreatedObjects.pop();
+
+ phase = Done;
+}
+
bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache, QObject *bindingTarget, QQmlPropertyData *valueTypeProperty, bool installPropertyCache, const QBitArray &bindingsToSkip)
{
const QV4::CompiledData::Object *obj = qmlUnit->objectAt(index);