From 6f08655ad68c447e7d0ad9d453288d9089a70bf0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 29 Jan 2021 13:42:07 +0100 Subject: QmlCompiler: Retain anonymous types in qmlnames Prefix them with $anonymous$ so that we cannot accidentally find them. If we don't keep them, they may be deleted when their last strong reference goes out of scope. Change-Id: I24ca795f9d9c4ecea074019db41a3ca0618f8e81 Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljsimporter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp index 5b693f5c72..823c0e6f2c 100644 --- a/src/qmlcompiler/qqmljsimporter.cpp +++ b/src/qmlcompiler/qqmljsimporter.cpp @@ -209,6 +209,8 @@ void QQmlJSImporter::processImport( QQmlJSImporter::AvailableTypes *types, const QString &prefix) { + const QString anonPrefix = QStringLiteral("$anonymous$"); + if (!prefix.isEmpty()) types->qmlNames.insert(prefix, {}); // Empty type means "this is the prefix" @@ -221,6 +223,11 @@ void QQmlJSImporter::processImport( types->cppNames.insert(val->internalName(), val); const auto exports = val->exports(); + if (exports.isEmpty()) { + types->qmlNames.insert( + prefixedName(prefix, prefixedName(anonPrefix, val->internalName())), val); + } + for (const auto &valExport : exports) types->qmlNames.insert(prefixedName(prefix, valExport.type()), val); } -- cgit v1.2.3