diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-01-15 14:47:35 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-01-23 15:58:10 +0100 |
commit | 684f9df7849bc79f1f02a60844fb43c7a3927d2f (patch) | |
tree | 531be4d102388395e4ddd2d14f38a679e15c283d /src/qml/qml/qqmltypecompiler.cpp | |
parent | 020a6e67766595351bcf911e965b26952a7c81b8 (diff) |
Long live QML inline components
[ChangeLog][QtQml] It is now possible to declare new QML components in
a QML file via the component keyword. They can be used just as if they
were declared in another file, with the only difference that the type
name needs to be prefixed with the name of the containing type outside
of the file were the inline component has been declared.
Notably, inline components are not closures: In the following
example, the output would be 42
// MyItem.qml
Item {
property int i: 33
component IC: Item {
Component.onCompleted: console.log(i)
}
}
// user.qml
Item {
property int i: 42
MyItem.IC {}
}
Fixes: QTBUG-79382
Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypecompiler.cpp')
-rw-r--r-- | src/qml/qml/qqmltypecompiler.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp index 7b4cf1a580..8d499bfe6a 100644 --- a/src/qml/qml/qqmltypecompiler.cpp +++ b/src/qml/qml/qqmltypecompiler.cpp @@ -58,10 +58,10 @@ QQmlTypeCompiler::QQmlTypeCompiler(QQmlEnginePrivate *engine, QQmlTypeData *type QV4::ResolvedTypeReferenceMap *resolvedTypeCache, const QV4::CompiledData::DependentTypesHasher &dependencyHasher) : resolvedTypes(resolvedTypeCache) , engine(engine) - , typeData(typeData) , dependencyHasher(dependencyHasher) - , typeNameCache(typeNameCache) , document(parsedQML) + , typeNameCache(typeNameCache) + , typeData(typeData) { } @@ -279,9 +279,9 @@ void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier document->imports.append(import); } -QQmlMetaType::CompositeMetaTypeIds QQmlTypeCompiler::typeIds() const +CompositeMetaTypeIds QQmlTypeCompiler::typeIdsForComponent(int objectId) const { - return typeData->typeIds(); + return typeData->typeIds(objectId); } QQmlCompilePass::QQmlCompilePass(QQmlTypeCompiler *typeCompiler) @@ -1221,7 +1221,7 @@ bool QQmlDeferredAndCustomParserBindingScanner::scanObject(int objectIndex) if (obj->idNameIndex != 0) _seenObjectWithId = true; - if (obj->flags & QV4::CompiledData::Object::IsComponent) { + if (obj->flags & QV4::CompiledData::Object::IsComponent && !obj->isInlineComponent) { Q_ASSERT(obj->bindingCount() == 1); const QV4::CompiledData::Binding *componentBinding = obj->firstBinding(); Q_ASSERT(componentBinding->type == QV4::CompiledData::Binding::Type_Object); |