Bootstrap: remove the ability to register custom QMetaTypes

Nothing was registering them, but moc does query types by name and that
searched the always-empty custom type database. This commit simplifies
the code a bit.

Change-Id: I7aac990cf04c9c514441fffdbb9faca471c92ffe
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Thiago Macieira 2025-01-08 00:29:49 -03:00
parent 74bdd85209
commit c1026f2ff0
2 changed files with 20 additions and 5 deletions

View File

@ -80,11 +80,13 @@ struct QMetaTypeDeleter
}
}
};
} // namespace
#ifndef QT_BOOTSTRAPPED
namespace {
struct QMetaTypeCustomRegistry
{
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
QMetaTypeCustomRegistry()
{
/* qfloat16 was neither a builtin, nor unconditionally registered
@ -165,7 +167,6 @@ struct QMetaTypeCustomRegistry
};
Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry)
} // namespace
// used by QVariant::save(): returns the name used in the Q_DECLARE_METATYPE
@ -205,6 +206,7 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte
return name;
}
#endif // !QT_BOOTSTRAPPED
/*!
\macro Q_DECLARE_OPAQUE_POINTER(PointerType)
@ -540,6 +542,7 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte
\sa qRegisterMetaType()
*/
#ifndef QT_BOOTSTRAPPED
/*!
\internal
Out-of-line path for registerType() and slow path id().
@ -553,6 +556,7 @@ int QMetaType::registerHelper(const QtPrivate::QMetaTypeInterface *iface)
}
return 0;
}
#endif
/*!
\fn constexpr qsizetype QMetaType::sizeOf() const
@ -887,7 +891,7 @@ bool QMetaType::isOrdered() const
return d_ptr && (d_ptr->flags & QMetaType::IsPointer || d_ptr->lessThan != nullptr);
}
#ifndef QT_BOOTSTRAPPED
/*!
\internal
*/
@ -910,6 +914,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
const_cast<QtPrivate::QMetaTypeInterface *>(d_ptr)->typeId.storeRelease(0);
}
#endif
/*!
\fn template<typename T> QMetaType QMetaType::fromType()
@ -2758,6 +2763,7 @@ static inline int qMetaTypeStaticType(const char *typeName, int length)
return types[i].type;
}
#ifndef QT_BOOTSTRAPPED
/*
Similar to QMetaType::type(), but only looks in the custom set of
types, and doesn't lock the mutex.
@ -2797,14 +2803,16 @@ void QMetaType::registerNormalizedTypedef(const NS(QByteArray) & normalizedTypeN
al = metaType.d_ptr;
}
}
#endif // !QT_BOOTSTRAPPED
static const QtPrivate::QMetaTypeInterface *interfaceForTypeNoWarning(int typeId)
{
const QtPrivate::QMetaTypeInterface *iface = nullptr;
if (typeId >= QMetaType::User) {
#ifndef QT_BOOTSTRAPPED
if (customTypeRegistry.exists())
iface = customTypeRegistry->getCustomType(typeId);
#endif
} else {
if (auto moduleHelper = qModuleHelperForType(typeId))
iface = moduleHelper->interfaceForType(typeId);
@ -2836,6 +2844,7 @@ static inline int qMetaTypeTypeImpl(const char *typeName, int length)
return QMetaType::UnknownType;
int type = qMetaTypeStaticType(typeName, length);
if (type == QMetaType::UnknownType) {
#ifndef QT_BOOTSTRAPPED
QReadLocker locker(&customTypeRegistry()->lock);
type = qMetaTypeCustomType_unlocked(typeName, length);
#ifndef QT_NO_QOBJECT
@ -2848,6 +2857,7 @@ static inline int qMetaTypeTypeImpl(const char *typeName, int length)
normalizedTypeName.size());
}
}
#endif
#endif
}
return type;

View File

@ -1351,6 +1351,10 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
return qRegisterNormalizedMetaTypeImplementation<T>(normalizedTypeName);
}
#if defined(QT_BOOTSTRAPPED)
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
#else
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT) \
QT_BEGIN_NAMESPACE \
EXPORT int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &); \
@ -1363,6 +1367,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &name) \
{ return qRegisterNormalizedMetaTypeImplementation< TYPE >(name); } \
/* end */
#endif
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT) \
QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TYPE, EXPORT)
#define QT_IMPL_METATYPE_EXTERN(TYPE) \