aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-04 03:02:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-06 21:51:18 +0100
commitb66cbe011ac843ab0aae3dfec45b313bc3280839 (patch)
tree8e6f2a6d25ff45a8cd13b1792ae27516dcae5f72
parent32b7e01558e0d3c50dd10f846182fe5dc09686e9 (diff)
[new compiler] Add support for parser status callbacks
Change-Id: I62ce1fab2537d533d1d2052a7f5edc5061adf75e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp38
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h2
-rw-r--r--src/qml/qml/qqmlparserstatus.h1
3 files changed, 41 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 81862a1429..4746188a8f 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -537,6 +537,10 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->importedScripts = parentContext->importedScripts;
}
+ QVector<QQmlParserStatus*> parserStatusCallbacks;
+ parserStatusCallbacks.resize(qmlUnit->nObjects);
+ qSwap(_parserStatusCallbacks, parserStatusCallbacks);
+
QObject *instance = createInstance(objectToCreate, parent);
if (instance) {
QQmlData *ddata = QQmlData::get(instance);
@@ -546,6 +550,10 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->contextObject = instance;
}
+
+ qSwap(_parserStatusCallbacks, parserStatusCallbacks);
+ allParserStatusCallbacks.prepend(parserStatusCallbacks);
+
return instance;
}
@@ -1242,6 +1250,13 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex)));
return 0;
}
+ const int parserStatusCast = type->parserStatusCast();
+ if (parserStatusCast != -1) {
+ QQmlParserStatus *parserStatus = reinterpret_cast<QQmlParserStatus*>(reinterpret_cast<char *>(instance) + parserStatusCast);
+ parserStatus->classBegin();
+ _parserStatusCallbacks[index] = parserStatus;
+ parserStatus->d = &_parserStatusCallbacks[index];
+ }
} else {
Q_ASSERT(typeRef.component);
if (typeRef.component->qmlUnit->isSingleton())
@@ -1258,6 +1273,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
if (subCreator.componentAttached)
subCreator.componentAttached->add(&componentAttached);
allCreatedBindings << subCreator.allCreatedBindings;
+ allParserStatusCallbacks << subCreator.allParserStatusCallbacks;
}
// ### use no-event variant
if (parent)
@@ -1321,6 +1337,28 @@ void QmlObjectCreator::finalize()
}
}
+ if (true /* ### componentCompleteEnabled()*/) { // the qml designer does the component complete later
+ QQmlTrace trace("VME Component Complete");
+ for (QLinkedList<QVector<QQmlParserStatus*> >::ConstIterator it = allParserStatusCallbacks.constBegin(), end = allParserStatusCallbacks.constEnd();
+ it != end; ++it) {
+ const QVector<QQmlParserStatus *> &parserStatusCallbacks = *it;
+ for (int i = parserStatusCallbacks.count() - 1; i >= 0; --i) {
+ QQmlParserStatus *status = parserStatusCallbacks.at(i);
+
+ if (status && status->d) {
+ status->d = 0;
+ status->componentComplete();
+ }
+
+ #if 0 // ###
+ if (watcher.hasRecursed() || interrupt.shouldInterrupt())
+ return 0;
+ #endif
+ }
+ }
+ allParserStatusCallbacks.clear();
+ }
+
{
QQmlTrace trace("VME Component.onCompleted Callbacks");
while (componentAttached) {
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index ec4b362491..900749a476 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -168,6 +168,7 @@ private:
const QList<QByteArray> vmeMetaObjectData;
QHash<int, int> objectIndexToId;
QLinkedList<QVector<QQmlAbstractBinding*> > allCreatedBindings;
+ QLinkedList<QVector<QQmlParserStatus*> > allParserStatusCallbacks;
QQmlCompiledData *compiledData;
QObject *_qobject;
@@ -180,6 +181,7 @@ private:
QVector<QQmlAbstractBinding*> _createdBindings;
QQmlListProperty<void> _currentList;
QV4::ExecutionContext *_qmlContext;
+ QVector<QQmlParserStatus*> _parserStatusCallbacks;
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlparserstatus.h b/src/qml/qml/qqmlparserstatus.h
index d3447e7752..1d63afd978 100644
--- a/src/qml/qml/qqmlparserstatus.h
+++ b/src/qml/qml/qqmlparserstatus.h
@@ -62,6 +62,7 @@ private:
friend class QQmlComponent;
friend class QQmlComponentPrivate;
friend class QQmlEnginePrivate;
+ friend class QmlObjectCreator;
QQmlParserStatus **d;
};