diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-20 08:32:21 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-20 14:15:40 +0000 |
commit | c884f85863d5cbb90d8a1f3972ddb37b3d3f7e14 (patch) | |
tree | 50b965353b684fc30647393e483f737ef956a29d /src/qml/qml/qqmltypeloader.cpp | |
parent | 7a1b5b1cfece18d5f4b2d8beb340d3cbe8f54451 (diff) |
Move type compilation independent bits out of QQmlTypeCompiler
The type validation is something that works on the final compilation
unit, so it can be done separately. The same applies to the composite
type registration and object/binding calculation. Both steps will
be shared with compilation units loaded from disk.
Change-Id: I43636d7ac76077c76289d7c1c9eba5e9c6b8239a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 0ba0384c60..1158cde5ca 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -49,6 +49,7 @@ #include <private/qqmlprofiler_p.h> #include <private/qqmlmemoryprofiler_p.h> #include <private/qqmltypecompiler_p.h> +#include <private/qqmlpropertyvalidator_p.h> #include <QtCore/qdir.h> #include <QtCore/qfile.h> @@ -445,6 +446,21 @@ void QQmlDataBlob::setError(const QQmlCompileError &error) setError(e); } +void QQmlDataBlob::setError(const QVector<QQmlCompileError> &errors) +{ + QList<QQmlError> finalErrors; + finalErrors.reserve(errors.count()); + for (const QQmlCompileError &error: errors) { + QQmlError e; + e.setColumn(error.location.column); + e.setLine(error.location.line); + e.setDescription(error.description); + e.setUrl(url()); + finalErrors << e; + } + setError(finalErrors); +} + void QQmlDataBlob::setError(const QString &description) { QQmlError e; @@ -2081,6 +2097,20 @@ void QQmlTypeData::done() compile(); if (!isError()) { + QQmlEnginePrivate * const engine = QQmlEnginePrivate::get(typeLoader()->engine()); + { + // Sanity check property bindings + QQmlPropertyValidator validator(engine, m_importCache, m_compiledData); + QVector<QQmlCompileError> errors = validator.validate(); + if (!errors.isEmpty()) { + setError(errors); + } + } + + m_compiledData->finalize(engine); + } + + if (!isError()) { QQmlType *type = QQmlMetaType::qmlType(finalUrl(), true); if (m_compiledData && m_compiledData->data->flags & QV4::CompiledData::Unit::IsSingleton) { if (!type) { |