From fac27251a68bfcea7fe926cc1baf36a3b4b41be6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 21 Sep 2021 11:26:18 +0200 Subject: [PATCH] QQmlJSImporter: Do not add QML names as C++ names Composite types need to be in the cppNames hash so that we don't lose them. However, we should hide them behind the "anonymous" prefix. Change-Id: Iaa0588233370631e6fde39dc61d5b8d31c963619 Reviewed-by: Qt CI Bot Reviewed-by: Andrei Golubev --- src/qmlcompiler/qqmljsimporter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp index f13d0e4ea3..a03f151045 100644 --- a/src/qmlcompiler/qqmljsimporter.cpp +++ b/src/qmlcompiler/qqmljsimporter.cpp @@ -224,7 +224,10 @@ void QQmlJSImporter::processImport(const QQmlJSImporter::Import &import, // add objects for (auto it = import.objects.begin(); it != import.objects.end(); ++it) { const auto &val = it.value(); - types->cppNames.insert(val->internalName(), val); + const QString name = val->isComposite() + ? prefixedName(anonPrefix, val->internalName()) + : val->internalName(); + types->cppNames.insert(name, val); const auto exports = val->exports(); if (exports.isEmpty()) {