aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Klitzing <aklitzing@gmail.com>2024-03-26 11:31:37 +0100
committerAndre Klitzing <aklitzing@gmail.com>2024-03-30 04:04:35 +0100
commit4c2c0e4bcd019d8d4a2ae840663ec5d7a15a6492 (patch)
treec23b853a1f010e967b320c24bbfc97eac78fd81f
parent4be7779ded3377f9ef524567b255645b997639d2 (diff)
Fix namespace in namespace detection of a foreign type
Add full qualified name to QML_FOREIGN, otherwise it won't detect a namespace in a namespace. Task-number: QTBUG-123535 Pick-to: 6.5 Change-Id: I679edc2566739ee52bf531ecec64789350fcdd11 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit fa081b89f0bf8813e11d00436ab0dc9fb5efb378) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 80fa9f25b3321ac2e8ae2c181505f4b1acee75d8)
-rw-r--r--src/qmltyperegistrar/qmetatypesjsonprocessor.cpp5
-rw-r--r--tests/auto/qml/qmltyperegistrar/enum.h11
2 files changed, 14 insertions, 2 deletions
diff --git a/src/qmltyperegistrar/qmetatypesjsonprocessor.cpp b/src/qmltyperegistrar/qmetatypesjsonprocessor.cpp
index df360bc44e..041e5b186e 100644
--- a/src/qmltyperegistrar/qmetatypesjsonprocessor.cpp
+++ b/src/qmltyperegistrar/qmetatypesjsonprocessor.cpp
@@ -128,6 +128,7 @@ QString MetaTypesJsonProcessor::extractRegisteredTypes() const
QString registrationHelper;
for (const auto &obj: m_types) {
const QString className = obj[u"className"].toString();
+ const QString qualifiedClassName = obj[u"qualifiedClassName"].toString();
const QString foreignClassName = className+ u"Foreign";
const auto classInfos = obj[u"classInfos"].toArray();
QString qmlElement;
@@ -162,10 +163,10 @@ QString MetaTypesJsonProcessor::extractRegisteredTypes() const
const QString spaces = u" "_s;
if (isNamespace) {
registrationHelper += u"\nnamespace "_s + foreignClassName + u"{\n Q_NAMESPACE\n"_s;
- registrationHelper += spaces + u"QML_FOREIGN_NAMESPACE(" + className + u")\n"_s;
+ registrationHelper += spaces + u"QML_FOREIGN_NAMESPACE(" + qualifiedClassName + u")\n"_s;
} else {
registrationHelper += u"\nstruct "_s + foreignClassName + u"{\n Q_GADGET\n"_s;
- registrationHelper += spaces + u"QML_FOREIGN(" + className + u")\n"_s;
+ registrationHelper += spaces + u"QML_FOREIGN(" + qualifiedClassName + u")\n"_s;
}
registrationHelper += spaces + qmlElement + u"\n"_s;
if (isSingleton)
diff --git a/tests/auto/qml/qmltyperegistrar/enum.h b/tests/auto/qml/qmltyperegistrar/enum.h
index 4a39c22545..7c10233b6f 100644
--- a/tests/auto/qml/qmltyperegistrar/enum.h
+++ b/tests/auto/qml/qmltyperegistrar/enum.h
@@ -16,4 +16,15 @@ namespace Hello {
Q_ENUM_NS(World)
}
+namespace Universe {
+ namespace Galaxy {
+ Q_NAMESPACE
+ QML_NAMED_ELEMENT(Solar)
+ enum class Solar {
+ Earth,
+ };
+ Q_ENUM_NS(Solar)
+ }
+}
+
#endif // ENUM_NS_HELLO_H