diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-08 13:50:46 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-04-09 08:52:56 +0200 |
commit | d0d4cc528ba9e3c39c15a2292066dac1d457abd5 (patch) | |
tree | e03506b1733f4eaf153c147577f40230a1c30004 /src/qml/qml/qqmlmetatype.cpp | |
parent | c08882be3a691ce93e12ef6ed388baa851247b14 (diff) |
Do not auto-clean components with live inline components
The inline components do not hold a strong reference to their outer type
because that would be a reference cycle.
Fixes: QTBUG-92236
Pick-to: 5.15 6.0 6.1
Change-Id: I6d76a114352653210f0ece6c198cf761d3b4eda1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatype.cpp')
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index d44cb9fdce..79bb95c8c2 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1306,6 +1306,16 @@ void QQmlMetaType::unregisterType(int typeIndex) } } +static bool hasActiveInlineComponents(const QQmlTypePrivate *d) +{ + for (const QQmlType &ic : qAsConst(d->objectIdToICType)) { + const QQmlTypePrivate *icPriv = ic.priv(); + if (icPriv && icPriv->count() > 1) + return true; + } + return false; +} + void QQmlMetaType::freeUnusedTypesAndCaches() { QQmlMetaTypeDataPtr data; @@ -1320,7 +1330,7 @@ void QQmlMetaType::freeUnusedTypesAndCaches() QList<QQmlType>::Iterator it = data->types.begin(); while (it != data->types.end()) { const QQmlTypePrivate *d = (*it).priv(); - if (d && d->count() == 1) { + if (d && d->count() == 1 && !hasActiveInlineComponents(d)) { deletedAtLeastOneType = true; removeQQmlTypePrivate(data->idToType, d); |