From dbed1f76ed83dc0cc850217a0d9926472ffa951b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 26 Apr 2024 23:59:13 +0300 Subject: [PATCH] partially revert 2fa4e0cdc51c670d80715cd124f61d324bbf903d prefixing the list with extra is really missleading, the reverted hunk is for the related metaobjects Signed-off-by: Ivailo Monev --- src/tools/moc/generator.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 975a51441..e78f19a61 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -256,6 +256,37 @@ void Generator::generateCode() if (cdef->hasQObject && !isQt) generateStaticMetacall(); +// +// Build extra array +// + QList extraList; + for (int i = 0; i < cdef->propertyList.count(); ++i) { + const PropertyDef &p = cdef->propertyList.at(i); + if (!isVariantType(p.type.constData()) && !metaTypes.contains(p.type) && !p.type.contains('*') && + !p.type.contains('<') && !p.type.contains('>')) { + int s = p.type.lastIndexOf("::"); + if (s > 0) { + QByteArray scope = p.type.left(s); + if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope)) + extraList += scope; + } + } + } + if (!extraList.isEmpty()) { + fprintf(out, "#ifdef Q_NO_DATA_RELOCATION\n"); + fprintf(out, "static const QMetaObjectAccessor qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); + for (int i = 0; i < extraList.count(); ++i) { + fprintf(out, " %s::getStaticMetaObject,\n", extraList.at(i).constData()); + } + fprintf(out, "#else\n"); + fprintf(out, "static const QMetaObject *qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); + for (int i = 0; i < extraList.count(); ++i) { + fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); + } + fprintf(out, "#endif //Q_NO_DATA_RELOCATION\n"); + fprintf(out, "\n};\n\n"); + } + // // Finally create and initialize the static meta object // @@ -277,7 +308,11 @@ void Generator::generateCode() else fprintf(out, " nullptr, "); - fprintf(out, "nullptr}\n};\n\n"); + if (extraList.isEmpty()) + fprintf(out, "nullptr"); + else + fprintf(out, "qt_meta_extradata_%s ", qualifiedClassNameIdentifier.constData()); + fprintf(out, "}\n};\n\n"); if(isQt) return;