summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecomponent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index cfef9cf485..0a2a6dbc51 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -733,48 +733,45 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons
return 0;
}
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ return begin(context, creationContext, cc, start, count, &state, 0, bindings);
+}
+
+QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentContext,
+ QDeclarativeContextData *componentCreationContext,
+ QDeclarativeCompiledData *component, int start, int count,
+ ConstructionState *state, QList<QDeclarativeError> *errors,
+ const QBitField &bindings)
+{
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(parentContext->engine);
+ bool isRoot = !enginePriv->inBeginCreate;
+
+ Q_ASSERT(!isRoot || state); // Either this isn't a root component, or a state data must be provided
+ Q_ASSERT((state != 0) ^ (errors != 0)); // One of state or errors (but not both) must be provided
- bool isRoot = !ep->inBeginCreate;
if (isRoot)
QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating);
- QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, cc->url);
QDeclarativeContextData *ctxt = new QDeclarativeContextData;
ctxt->isInternal = true;
- ctxt->url = cc->url;
- ctxt->imports = cc->importCache;
+ ctxt->url = component->url;
+ ctxt->imports = component->importCache;
// Nested global imports
- if (creationContext && start != -1)
- ctxt->importedScripts = creationContext->importedScripts;
-
- cc->importCache->addref();
- ctxt->setParent(context);
+ if (componentCreationContext && start != -1)
+ ctxt->importedScripts = componentCreationContext->importedScripts;
- QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings);
+ component->importCache->addref();
+ ctxt->setParent(parentContext);
- if (ep->isDebugging && rv) {
- if (!context->isInternal)
- context->asQDeclarativeContextPrivate()->instances.append(rv);
- QDeclarativeEngineDebugServer::instance()->objectCreated(engine, rv);
- }
-
- return rv;
-}
-
-QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv,
- QDeclarativeCompiledData *component, int start, int count,
- ConstructionState *state, const QBitField &bindings)
-{
- bool isRoot = !enginePriv->inBeginCreate;
enginePriv->inBeginCreate = true;
QDeclarativeVME vme;
QObject *rv = vme.run(ctxt, component, start, count, bindings);
- if (vme.isError())
- state->errors = vme.errors();
+ if (vme.isError()) {
+ if(errors) *errors = vme.errors();
+ else state->errors = vme.errors();
+ }
if (isRoot) {
enginePriv->inBeginCreate = false;
@@ -794,6 +791,12 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe
enginePriv->inProgressCreations++;
}
+ if (enginePriv->isDebugging && rv) {
+ if (!parentContext->isInternal)
+ parentContext->asQDeclarativeContextPrivate()->instances.append(rv);
+ QDeclarativeEngineDebugServer::instance()->objectCreated(parentContext->engine, rv);
+ }
+
return rv;
}