From 74fac865cf7c55d3afba1043072ba6cc932d161d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Jul 2022 12:31:07 -0700 Subject: QMetaType: add registerType() and qRegisterMetaType(QMetaType) This also rewrites QMetaType::id() on top of the helper, with the benefit of calling a member static function, so QMetaType doesn't need to be spilled onto the stack. In some upcoming changes I need to ensure that QMetaTypes are registered so they can be found by name and I'd like to have a dedicated function name for that, instead of calling .id(). Since I needed to add docs for the new function, I've updated for the old one too. [ChangeLog][QMetaType] Added QMetaType::registerType() and an overload of qRegisterMetaType() taking QMetaType (the two functions do the same thing). These two functions ensure a given QMetaType is registered with the Qt global registry, so they can be found by name later. Using qRegisterMetaType() also accomplishes the same thing, but is slightly better for completely generic code because it will avoid emitting the registration for built-in types. Change-Id: I3859764fed084846bcb0fffd170351d606034c22 Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale --- src/corelib/compat/removed_api.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/corelib/compat/removed_api.cpp') diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index c4fe85f84f..7ffefa027e 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -283,6 +283,14 @@ QT_WARNING_POP #if QT_CORE_REMOVED_SINCE(6, 5) +#include "qmetatype.h" + +int QMetaType::idHelper() const +{ + Q_ASSERT(d_ptr); + return registerHelper(d_ptr); +} + #include "qxmlstream.h" QXmlStreamReader::QXmlStreamReader(const QByteArray &data) -- cgit v1.2.3