diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-12-03 12:35:16 +0100 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-12-06 14:41:53 +0100 |
| commit | 637ccf5332010b2b6480697993a779457702fd70 (patch) | |
| tree | e6d11d4ee57e17398655ab9e6fec3eeebb5b87b6 /src/corelib/kernel/qmetaobject.cpp | |
| parent | 746dba248eea494fe53fe81108e1f880cb095651 (diff) | |
QMetaObject: Include a class def's hash in the meta object
The hash has the following format <hash_revision>$<hash_b64>, where
hash_revision is an integer and hash_b64 is the base64 encoding of the
hash.
MetaObjects built using QMetaObjectBuilder do not yet support the hash.
That will need to be added at a later point.
Task-number: QTBUG-142186
Change-Id: Ifafc7df2202decf48e8a1a45e652c2f61c5cea64
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
| -rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 24cc58829c8..c7e50788b45 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -469,6 +469,33 @@ QMetaType QMetaObject::metaType() const } } +static inline QByteArrayView objectMetaObjectHash(const QMetaObject *m) +{ + // metaObjectHash didn't exist before revision 14 + if (QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && priv(m->d.data)->revision < 14) + return {}; + const auto index = priv(m->d.data)->metaObjectHashIndex; + if (index == -1) + return {}; + return stringDataView(m, index); +} + +/*! + \since 6.11 + + Returns the revisioned hash of the contents of this QMetaObject or nullptr. + + The hash has the following format <hash_revision>$<hash_b64>, where + hash_revision is an integer and hash_b64 is the base64 encoding of the + hash. + + Note that only hashes of the same revision should be compared. +*/ +const char *QMetaObject::metaObjectHash() const +{ + return objectMetaObjectHash(this).constData(); +} + /*! Returns the method offset for this class; i.e. the index position of this class's first member function. |
