summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <[email protected]>2025-06-17 12:49:50 -0700
committerThiago Macieira <[email protected]>2025-06-21 14:39:28 -0700
commiteadfa2ce04481c9d6a6496675f77a0557bca9761 (patch)
treef8214e98e2688ef12eed08a953bc775910b227ca
parent857f1e4462d705dec118467f75467be271ae7599 (diff)
moc: stop using qMetaTypeTypeInternal
Just use QMetaType::fromName(). We bypass the id() call because anything that came from the registry is, by definition, registered. Besides, inside a bootstrapped tool, there are no custom types anyway. Drive-by static'ify the functions. Pick-to: 6.10 Change-Id: Ib8363744834da6d79046fffd0adb680219c829e0 Reviewed-by: Ahmad Samir <[email protected]>
-rw-r--r--src/tools/moc/generator.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 3d2d5da1e62..2e93cac7d5a 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -26,13 +26,30 @@ QT_BEGIN_NAMESPACE
using namespace QtMiscUtils;
-uint nameToBuiltinType(const QByteArray &name)
+static int nameToBuiltinType(const QByteArray &name)
{
if (name.isEmpty())
return 0;
- uint tp = qMetaTypeTypeInternal(name.constData());
- return tp < uint(QMetaType::User) ? tp : uint(QMetaType::UnknownType);
+ uint tp = QMetaType::UnknownType;
+ if (const QtPrivate::QMetaTypeInterface *iface = QMetaType::fromName(name).iface())
+ tp = iface->typeId.loadRelaxed(); // always registered
+
+#ifndef QT_BOOTSTRAPPED
+ if (tp >= uint(QMetaType::User))
+ tp = QMetaType::UnknownType;
+#endif
+
+ return int(tp);
+}
+
+/*
+ Returns \c true if the type is a built-in type.
+*/
+static bool isBuiltinType(const QByteArray &type)
+{
+ int id = nameToBuiltinType(type);
+ return id != QMetaType::UnknownType;
}
constexpr const char *cxxTypeTag(TypeTags t)
@@ -49,17 +66,6 @@ constexpr const char *cxxTypeTag(TypeTags t)
return "";
}
-/*
- Returns \c true if the type is a built-in type.
-*/
-bool isBuiltinType(const QByteArray &type)
- {
- int id = qMetaTypeTypeInternal(type.constData());
- if (id == QMetaType::UnknownType)
- return false;
- return (id < QMetaType::User);
-}
-
static const char *metaTypeEnumValueString(int type)
{
#define RETURN_METATYPENAME_STRING(MetaTypeName, MetaTypeId, RealType) \