aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypedata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmltypedata.cpp')
-rw-r--r--src/qml/qml/qqmltypedata.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index cd4e0acf39..fc1d0cfbcf 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -300,7 +300,14 @@ void QQmlTypeData::setCompileUnit(const Container &container)
auto const root = container->objectAt(i);
for (auto it = root->inlineComponentsBegin(); it != root->inlineComponentsEnd(); ++it) {
auto *typeRef = m_compiledData->resolvedType(it->nameIndex);
- typeRef->compilationUnit = m_compiledData; // share compilation unit
+
+ // We don't want the type reference to keep a strong reference to the compilation unit
+ // here. The compilation unit owns the type reference, and having a strong reference
+ // would prevent the compilation unit from ever getting deleted. We can still be sure
+ // that the compilation unit outlives the type reference, due to ownership.
+ typeRef->setReferencesCompilationUnit(false);
+
+ typeRef->setCompilationUnit(m_compiledData); // share compilation unit
}
}
}
@@ -919,7 +926,7 @@ QQmlError QQmlTypeData::buildTypeResolutionCaches(
if (resolvedType->needsCreation && qmlType.isCompositeSingleton()) {
return qQmlCompileError(resolvedType->location, tr("Composite Singleton Type %1 is not creatable.").arg(qmlType.qmlTypeName()));
}
- ref->compilationUnit = resolvedType->typeData->compilationUnit();
+ ref->setCompilationUnit(resolvedType->typeData->compilationUnit());
if (resolvedType->type.isInlineComponentType()) {
// Inline component which is part of an already resolved type
int objectId = -1;
@@ -943,12 +950,12 @@ QQmlError QQmlTypeData::buildTypeResolutionCaches(
auto typeID = qmlType.lookupInlineComponentById(qmlType.inlineComponendId()).typeId();
auto exUnit = engine->obtainExecutableCompilationUnit(typeID);
if (exUnit) {
- ref->compilationUnit = exUnit;
+ ref->setCompilationUnit(exUnit);
ref->typePropertyCache = engine->propertyCacheForType(typeID);
}
}
} else {
- ref->compilationUnit = m_inlineComponentToCompiledData[resolvedType.key()];
+ ref->setCompilationUnit(m_inlineComponentToCompiledData[resolvedType.key()]);
ref->typePropertyCache = m_inlineComponentToCompiledData[resolvedType.key()]->rootPropertyCache();
}