QQmlTypeCompiler: Find implicit components for inline component roots
Pick-to: 6.2 6.3 Fixes: QTBUG-102719 Change-Id: Ia6654f617d9d0922c94a5e204f9559e95c529641 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
dc815b797c
commit
95837745e4
|
@ -876,7 +876,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(
|
|||
}
|
||||
}
|
||||
|
||||
// resolve ignores everything relating to inline components
|
||||
// Resolve ignores everything relating to inline components, except for implicit components.
|
||||
bool QQmlComponentAndAliasResolver::resolve(int root)
|
||||
{
|
||||
// Detect real Component {} objects as well as implicitly defined components, such as
|
||||
|
@ -891,25 +891,31 @@ bool QQmlComponentAndAliasResolver::resolve(int root)
|
|||
= obj->flags & QV4::CompiledData::Object::IsInlineComponentRoot;
|
||||
const bool isPartOfInlineComponent
|
||||
= obj->flags & QV4::CompiledData::Object::IsPartOfInlineComponent;
|
||||
if (root == 0) {
|
||||
// normal component root, skip over anything inline component related
|
||||
if (isInlineComponentRoot || isPartOfInlineComponent)
|
||||
continue;
|
||||
} else if (!isPartOfInlineComponent || isInlineComponentRoot) {
|
||||
break; // left current inline component (potentially entered a new one)
|
||||
}
|
||||
QQmlPropertyCache::ConstPtr cache = propertyCaches.at(i);
|
||||
if (obj->inheritedTypeNameIndex == 0 && !cache)
|
||||
continue;
|
||||
|
||||
bool isExplicitComponent = false;
|
||||
|
||||
if (obj->inheritedTypeNameIndex) {
|
||||
auto *tref = resolvedType(obj->inheritedTypeNameIndex);
|
||||
Q_ASSERT(tref);
|
||||
if (tref->type().metaObject() == &QQmlComponent::staticMetaObject)
|
||||
isExplicitComponent = true;
|
||||
}
|
||||
|
||||
if (root == 0) {
|
||||
// normal component root, skip over anything inline component related
|
||||
if (isInlineComponentRoot || isPartOfInlineComponent)
|
||||
continue;
|
||||
} else if (!isPartOfInlineComponent || isInlineComponentRoot) {
|
||||
// We've left the current inline component (potentially entered a new one),
|
||||
// but we still need to resolve implicit components which are part of inline components.
|
||||
if (cache && !isExplicitComponent)
|
||||
findAndRegisterImplicitComponents(obj, cache);
|
||||
break;
|
||||
}
|
||||
|
||||
if (obj->inheritedTypeNameIndex == 0 && !cache)
|
||||
continue;
|
||||
|
||||
if (!isExplicitComponent) {
|
||||
if (cache)
|
||||
findAndRegisterImplicitComponents(obj, cache);
|
||||
|
|
|
@ -9,5 +9,10 @@ QtObject {
|
|||
property QtObject view: View { delegate: QtObject {} }
|
||||
}
|
||||
|
||||
component Delegated : View {
|
||||
delegate: QtObject {}
|
||||
}
|
||||
|
||||
property Things things: Things {}
|
||||
property Delegated delegated: Delegated {}
|
||||
}
|
||||
|
|
|
@ -6923,11 +6923,16 @@ void tst_qqmllanguage::componentMix()
|
|||
QVERIFY(!o.isNull());
|
||||
QObject *things = qvariant_cast<QObject *>(o->property("things"));
|
||||
QVERIFY(things);
|
||||
QObject *delegated = qvariant_cast<QObject *>(o->property("delegated"));
|
||||
QVERIFY(delegated);
|
||||
QObject *view = qvariant_cast<QObject *>(things->property("view"));
|
||||
QVERIFY(view);
|
||||
QObject *delegate = qvariant_cast<QObject *>(view->property("delegate"));
|
||||
QVERIFY(delegate);
|
||||
QCOMPARE(delegate->metaObject(), &QQmlComponent::staticMetaObject);
|
||||
QObject *delegate2 = qvariant_cast<QObject *>(delegated->property("delegate"));
|
||||
QVERIFY(delegate2);
|
||||
QCOMPARE(delegate2->metaObject(), &QQmlComponent::staticMetaObject);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qqmllanguage)
|
||||
|
|
Loading…
Reference in New Issue