aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-29 13:42:07 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-29 16:52:04 +0100
commit6f08655ad68c447e7d0ad9d453288d9089a70bf0 (patch)
tree72e1f5a769e0159e38d2e7d54671f90940651cd4 /src/qmlcompiler
parent9ce33872c979019cfaa13fd480fb620639e6c46e (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler')
-rw-r--r--src/qmlcompiler/qqmljsimporter.cpp7
1 files changed, 7 insertions, 0 deletions
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);
}