diff options
author | Fabian Kosmale <[email protected]> | 2023-03-13 09:36:09 +0100 |
---|---|---|
committer | Fabian Kosmale <[email protected]> | 2023-03-13 20:03:15 +0000 |
commit | b68ad5ef7fd8df0ef4aea03f33dfe05fd8272469 (patch) | |
tree | 3e9d249d53e2979d35fd47a37de61e1179b556ba | |
parent | 973f499cca4d5017c902249361ec02e025e148cf (diff) |
QMetaType: Ensure that qfloat16 gets correct id
Code initially compiled against Qt <= 6.2 does not have a qfloat16
metatype that unconditionally gets registeret from QtBase.
Therefore, any preexisting metatype instance for qfloat16 will hit the
custom type registry code path. As builtin metatypes are not part of the
custom registry, we will create a new type-id, and the type will thus
not compare equal to new code using the builtin type-id.
Avoid this issue by inserting an alias to the type in
QMetaTypeCustomRegistry's constructor.
Pick-to: 6.5 dev
Change-Id: I825265ad16e274c08b2c4a3a4814475b6c6c6187
Reviewed-by: Volker Hilsheimer <[email protected]>
Reviewed-by: Marc Mutz <[email protected]>
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 139c4ec7762..bf75e176b8e 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -84,6 +84,20 @@ struct QMetaTypeDeleter struct QMetaTypeCustomRegistry { + +#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) + QMetaTypeCustomRegistry() + { + /* qfloat16 was neither a builtin, nor unconditionally registered + in QtCore in Qt <= 6.2. + Inserting it as an alias ensures that a QMetaType::id call + will get the correct built-in type-id (the interface pointers + might still not match, but we already deal with that case. + */ + aliases.insert("qfloat16", QtPrivate::qMetaTypeInterfaceForType<qfloat16>()); + } +#endif + QReadWriteLock lock; QList<const QtPrivate::QMetaTypeInterface *> registry; QHash<QByteArray, const QtPrivate::QMetaTypeInterface *> aliases; |