diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-08 11:05:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-12 23:00:19 +0200 |
commit | 346662cb011b7962a8cabf6d55742cd050a6ba6c (patch) | |
tree | ef71f9e15cfb6816c793eff5c9c097cf2d121ff9 /src/qml/qml/qqmlobjectcreator_p.h | |
parent | 845b07dad47e63bf285461433f4321d71c6c343d (diff) |
Fix error reporting timing
Errors for example in signal declarations are usually reported in the loader
thread, during property cache construction. This patch separates out the
property cache population into QQmlPropertyCacheCreator, runs it from the
loader thread and reduces the QQmlObjectCreator to merely set the properties/bindings/
functions on the object.
This also enables location tracking for signal declarations and their error reporting.
Change-Id: Ief1ffbb3113f8279a50d1a12dab8dbe096702a60
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator_p.h')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index de868560e9..fc7aa2040c 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -49,17 +49,34 @@ QT_BEGIN_NAMESPACE class QQmlAbstractBinding; -namespace QtQml { +class QQmlPropertyCacheCreator +{ + Q_DECLARE_TR_FUNCTIONS(QQmlPropertyCacheCreator) +public: + QQmlPropertyCacheCreator(QQmlEnginePrivate *enginePrivate, const QV4::CompiledData::QmlUnit *unit, + const QUrl &url, QQmlTypeNameCache *typeNameCache, const QQmlImports *imports); + + QList<QQmlError> errors; + + bool create(const QV4::CompiledData::Object *obj, QQmlPropertyCache **cache, QByteArray *vmeMetaObjectData); + +protected: + QString stringAt(int idx) const { return unit->header.stringAt(idx); } + void recordError(const QV4::CompiledData::Location &location, const QString &description); + + QQmlEnginePrivate *enginePrivate; + const QV4::CompiledData::QmlUnit *unit; + QUrl url; + QQmlTypeNameCache *typeNameCache; + const QQmlImports *imports; +}; -class Q_QML_EXPORT QmlObjectCreator +class QmlObjectCreator { Q_DECLARE_TR_FUNCTIONS(QQmlCompiler) public: - - QmlObjectCreator(QQmlEngine *engine, const QUrl &url, - // extra data/output stored in these two - QQmlContextData *contextData, - QQmlCompiledData *runtimeData); + QmlObjectCreator(QQmlContextData *contextData, const QV4::CompiledData::QmlUnit *qmlUnit, const QV4::CompiledData::CompilationUnit *jsUnit, + QQmlTypeNameCache *typeNameCache, const QList<QQmlPropertyCache *> &propertyCaches, const QList<QByteArray> &vmeMetaObjectData); QObject *create(QObject *parent = 0) { return create(unit->indexOfRootObject, parent); } @@ -67,15 +84,9 @@ public: QList<QQmlError> errors; - static bool needsCustomMetaObject(const QV4::CompiledData::Object *obj); - bool createVMEMetaObjectAndPropertyCache(const QV4::CompiledData::Object *obj, QQmlPropertyCache *baseTypeCache, - // out parameters - QQmlPropertyCache **cache, QByteArray *vmeMetaObjectData); private: - QString stringAt(int idx) const { return unit->header.stringAt(idx); } - - QVector<QQmlAbstractBinding *> setupBindings(const QV4::CompiledData::Object *obj, QV4::Object *qmlGlobal); - void setupFunctions(const QV4::CompiledData::Object *obj, QV4::Object *qmlGlobal); + QVector<QQmlAbstractBinding *> setupBindings(QV4::Object *qmlGlobal); + void setupFunctions(QV4::Object *qmlGlobal); QVariant variantForBinding(int expectedMetaType, const QV4::CompiledData::Binding *binding) const; @@ -83,6 +94,7 @@ private: static double valueAsNumber(const QV4::CompiledData::Value *value); static bool valueAsBoolean(const QV4::CompiledData::Value *value); + QString stringAt(int idx) const { return unit->header.stringAt(idx); } void recordError(const QV4::CompiledData::Location &location, const QString &description); QQmlEngine *engine; @@ -91,16 +103,15 @@ private: const QV4::CompiledData::CompilationUnit *jsUnit; QQmlContextData *context; QQmlTypeNameCache *typeNameCache; - QQmlCompiledData *runtimeData; - QQmlImports imports; + const QList<QQmlPropertyCache *> propertyCaches; + const QList<QByteArray> vmeMetaObjectData; - QObject *_object; + QObject *_qobject; + const QV4::CompiledData::Object *_compiledObject; QQmlData *_ddata; QQmlRefPointer<QQmlPropertyCache> _propertyCache; }; -} // end namespace QtQml - QT_END_NAMESPACE #endif // QQMLOBJECTCREATOR_P_H |