summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-02 09:05:05 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-05 10:49:37 +0200
commit481d70818e9bb157e9167a0a2817a7e9254a5eca (patch)
tree14d1251bbc49e64b7987fa6fd02cc4243979fc8b
parentf4d1e7a841b039c35eb5bf6f0180564976539970 (diff)
downloadqtactiveqt-481d70818e9bb157e9167a0a2817a7e9254a5eca.tar.gz
Follow up on meta object version bump in qtbase
After b83de5f9a43b094bbb77b3aeea77983ea508a2b0 in qtbase, moc generates complete type information for enum types. ActiveQt declares enums from type libraries (i.e. on namespace level) also in the metaobject of each generated class (as we can't inherit the namespace meta object from each QAxObject class). But those enum types don't really exist on C++ level. So moc generates incorrectly qualified enum types. Augment the post-processing code to detect whether a type that is actually in the namespace is used as if it was in the class, and replace the qualifier. Bump the metaobject revision. Change-Id: I4d28abaa47a5fa3db70737d006b8e1becf8a51e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tools/dumpcpp/main.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp
index 9820a76..1b6fbeb 100644
--- a/tools/dumpcpp/main.cpp
+++ b/tools/dumpcpp/main.cpp
@@ -537,12 +537,13 @@ bool generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray
bool useControlName,
QString *errorString)
{
- Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 11, "dumpcpp should generate the same version as moc");
+ Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 12, "dumpcpp should generate the same version as moc");
QByteArray qualifiedClassName;
if (!nameSpace.isEmpty())
qualifiedClassName = nameSpace + "::";
qualifiedClassName += className;
+ const QByteArray nestedQualifier = className + "::";
QString moCode = mocCode(mo, QLatin1String(qualifiedClassName), errorString);
if (moCode.isEmpty()) {
@@ -567,7 +568,21 @@ bool generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray
if (type.endsWith(u'*'))
type.chop(1);
type = type.trimmed();
- const auto namespaceForTypeEntry = namespaceForType.constFind(type.toUtf8());
+
+ // If ActiveQt thinks it's a nested type within the class, but it really is a type in the
+ // namespace, then we need to replace the nested type qualifier with the real namespace.
+ const bool isNestedType = type.startsWith(QString::fromUtf8(nestedQualifier));
+ auto namespaceForTypeEntry = namespaceForType.constEnd();
+ if (isNestedType) {
+ const QString rawType = type.mid(nestedQualifier.length());
+ namespaceForTypeEntry = namespaceForType.constFind(rawType.toUtf8());
+ if (namespaceForTypeEntry != namespaceForType.constEnd()) {
+ moCode.remove(startType, nestedQualifier.length());
+ type = rawType;
+ }
+ }
+ if (namespaceForTypeEntry == namespaceForType.constEnd())
+ namespaceForTypeEntry = namespaceForType.constFind(type.toUtf8());
if (namespaceForTypeEntry != namespaceForType.constEnd()) {
const auto ns = QString::fromUtf8(namespaceForTypeEntry.value());
moCode.insert(startType, ns + QStringView(u"::"));