diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 9a57f46cbfa..1c2665e53c0 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -2659,6 +2659,36 @@ bool QMetaType::hasRegisteredConverterFunction(QMetaType fromType, QMetaType toT return customTypesConversionRegistry()->contains({fromType.id(), toType.id()}); } +/*! + \internal + Non-template helper ("SCARY") for IsMetaTypePair::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToPairVariantInterface(QMetaType m) +{ + const QMetaType to = QMetaType::fromType(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for SequentialValueTypeIsMetaType::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType m) +{ + const QMetaType to = QMetaType::fromType>(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for AssociativeKeyTypeIsMetaType::registerConverter(). +*/ +bool QtPrivate::hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType m) +{ + const QMetaType to = QMetaType::fromType>(); + return QMetaType::hasRegisteredConverterFunction(m, to); +} + /*! \fn template bool QMetaType::hasRegisteredMutableViewFunction() Returns \c true, if the meta type system has a registered mutable view on type From of type To. @@ -2676,6 +2706,26 @@ bool QMetaType::hasRegisteredMutableViewFunction(QMetaType fromType, QMetaType t return customTypesMutableViewRegistry()->contains({fromType.id(), toType.id()}); } +/*! + \internal + Non-template helper ("SCARY") for SequentialValueTypeIsMetaType::registerMutableView(). +*/ +bool QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType m) +{ + const QMetaType to = QMetaType::fromType>(); + return QMetaType::hasRegisteredMutableViewFunction(m, to); +} + +/*! + \internal + Non-template helper ("SCARY") for AssociativeKeyTypeIsMetaType::registerMutableView(). +*/ +bool QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType m) +{ + const QMetaType to = QMetaType::fromType>(); + return QMetaType::hasRegisteredMutableViewFunction(m, to); +} + /*! \fn const char *QMetaType::typeName(int typeId) \deprecated diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 80d10f5c9ab..12a67aef584 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1750,11 +1750,19 @@ QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE) QT_BEGIN_NAMESPACE +namespace QtPrivate { +// out-of-line helpers to reduce template code bloat ("SCARY") and improve compile times: +Q_CORE_EXPORT bool hasRegisteredConverterFunctionToPairVariantInterface(QMetaType m); +Q_CORE_EXPORT bool hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType m); +Q_CORE_EXPORT bool hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType m); +Q_CORE_EXPORT bool hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType m); +Q_CORE_EXPORT bool hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType m); +} + template inline bool QtPrivate::IsMetaTypePair::registerConverter() { - const QMetaType to = QMetaType::fromType(); - if (!QMetaType::hasRegisteredConverterFunction(QMetaType::fromType(), to)) { + if (!QtPrivate::hasRegisteredConverterFunctionToPairVariantInterface(QMetaType::fromType())) { QtMetaTypePrivate::QPairVariantInterfaceConvertFunctor o; return QMetaType::registerConverter(o); } @@ -1786,8 +1794,7 @@ struct SequentialValueTypeIsMetaType { static bool registerConverter() { - const QMetaType to = QMetaType::fromType>(); - if (!QMetaType::hasRegisteredConverterFunction(QMetaType::fromType(), to)) { + if (!QtPrivate::hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType::fromType())) { QSequentialIterableConvertFunctor o; return QMetaType::registerConverter>(o); } @@ -1796,8 +1803,7 @@ struct SequentialValueTypeIsMetaType static bool registerMutableView() { - const QMetaType to = QMetaType::fromType>(); - if (!QMetaType::hasRegisteredMutableViewFunction(QMetaType::fromType(), to)) { + if (!QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType::fromType())) { QSequentialIterableMutableViewFunctor o; return QMetaType::registerMutableView>(o); } @@ -1830,8 +1836,7 @@ struct AssociativeKeyTypeIsMetaType : AssociativeMappedTypeIsMetaType>(); - if (!QMetaType::hasRegisteredConverterFunction(QMetaType::fromType(), to)) { + if (!QtPrivate::hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType::fromType())) { QAssociativeIterableConvertFunctor o; return QMetaType::registerConverter>(o); } @@ -1840,8 +1845,7 @@ struct AssociativeKeyTypeIsMetaType : AssociativeMappedTypeIsMetaType>(); - if (!QMetaType::hasRegisteredMutableViewFunction(QMetaType::fromType(), to)) { + if (!QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType::fromType())) { QAssociativeIterableMutableViewFunctor o; return QMetaType::registerMutableView>(o); }