diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-10-07 15:13:38 +0200 |
|---|---|---|
| committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-10-08 15:40:06 +0200 |
| commit | d392d3b22c94f86fea50f26284bc9ac8b35f6851 (patch) | |
| tree | 27ee3c33714715e7ddd59938832375479d410c41 /src/corelib/kernel/qmetaobjectbuilder.cpp | |
| parent | fc08a07a0035b3398cf009fef1ab4956ab4b60ce (diff) | |
QMetaObjectBuilder: Fix construction logic for enums
We need to put metatypes in the correct place; this is especially vital
starting with Qt 6.9, given that we need it to query it to figure out
whether we have a 64bit value or not.
As a drive-by, replace some ugly casting when constructing the meta-type
array with a call to QMetaType::iface.
Pick-to: 6.8
Change-Id: I4b1f42f974e9f7a21f6aa4c87c3f8919f6965d6e
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobjectbuilder.cpp')
| -rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 9d3d3266b2a..96b25bd3722 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1253,8 +1253,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Output the methods in the class. Q_ASSERT(!buf || dataIndex == pmeta->methodData); - // + 1 for metatype of this metaobject - int parameterMetaTypesIndex = int(d->properties.size()) + 1; + // property count + enum count + 1 for metatype of this metaobject + int parameterMetaTypesIndex = int(d->properties.size()) + int(d->enumerators.size()) + 1; for (const auto &method : d->methods) { [[maybe_unused]] int name = strings.enter(method.name()); int argc = method.parameterCount(); @@ -1418,12 +1418,19 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, } ALIGN(size, QtPrivate::QMetaTypeInterface *); - auto types = reinterpret_cast<QtPrivate::QMetaTypeInterface **>(buf + size); + auto types = reinterpret_cast<const QtPrivate::QMetaTypeInterface **>(buf + size); if constexpr (mode == Construct) { meta->d.metaTypes = types; for (const auto &prop : d->properties) { QMetaType mt = prop.metaType; - *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt); + *types = mt.iface(); + types++; + } + // add metatypes for enumerators + for (const auto &enumerator: d->enumerators) { + QMetaType mt = enumerator.metaType; + mt.registerType(); + *types = mt.iface(); types++; } // add metatype interface for this metaobject - must be null @@ -1436,14 +1443,14 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, types++; for (const auto ¶meterType: method.parameterTypes()) { QMetaType mt = QMetaType::fromName(parameterType); - *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt); + *types = mt.iface(); types++; } } for (const auto &constructor : d->constructors) { for (const auto ¶meterType : constructor.parameterTypes()) { QMetaType mt = QMetaType::fromName(parameterType); - *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt); + *types = mt.iface(); types++; } } |
