moc: put the qt_meta_stringdata_XXXX_t type in an unnamed namespace

Not all user code is compiled with hidden visibility, so make sure one
of the types in the template parameters (the one that is supposed to be
unique anyway) is local and therefore causes the full symbol for the
inline variable not to be exported outside of the translation unit.

Pick-to: 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fb262a59b81283
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Thiago Macieira 2022-06-22 21:40:51 -07:00
parent 0978646a65
commit 8726647df4
1 changed files with 6 additions and 1 deletions

View File

@ -249,6 +249,9 @@ void Generator::generateCode()
QByteArray qualifiedClassNameIdentifier = cdef->qualified;
qualifiedClassNameIdentifier.replace(':', '_');
// ensure the qt_meta_stringdata_XXXX_t type is local
fprintf(out, "namespace {\n");
//
// Build stringdata struct
//
@ -294,7 +297,9 @@ void Generator::generateCode()
// Terminate stringdata struct
fprintf(out, "\n};\n");
fprintf(out, "#undef QT_MOC_LITERAL\n\n");
fprintf(out, "#undef QT_MOC_LITERAL\n");
fprintf(out, "} // unnamed namespace\n\n");
//
// build the data array