diff options
author | Thiago Macieira <[email protected]> | 2025-06-11 09:19:33 -0700 |
---|---|---|
committer | Thiago Macieira <[email protected]> | 2025-07-08 11:39:16 -0700 |
commit | 8f498cf95baa7d6d2443ec0c0929656428f36cce (patch) | |
tree | ca1154b82c06544dc08c9e539476fbb5045bea26 | |
parent | 5f89ae8faa1b3eebe32fa4e8081fb643dc06b834 (diff) |
QVariant already registers any type it gets, so we don't need
QMetaType::id() to attempt to register again. Saves a bit of code
wherever it gets used.
Pick-to: 6.10
Change-Id: I91f5792eb04fdf263142fffd44f8257041afdd0e
Reviewed-by: Fabian Kosmale <[email protected]>
-rw-r--r-- | src/corelib/kernel/qvariant.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 31f5869c9d9..e9d3ffb9ae3 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -332,7 +332,16 @@ public: inline void swap(QVariant &other) noexcept { std::swap(d, other.d); } int userType() const { return typeId(); } - int typeId() const { return metaType().id(); } + int typeId() const + { + // QVariant types are always registered (see fromMetaType()) + const QtPrivate::QMetaTypeInterface *mt = metaType().iface(); + if (!mt) + return 0; + int id = mt->typeId.loadRelaxed(); + // Q_ASSUME(id > 0); + return id; + } const char *typeName() const; QMetaType metaType() const; |