diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 18d59e1298..ae13590658 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -843,7 +843,11 @@ namespace QtPrivate } // namespace detail template - struct is_complete : detail::is_complete_helper::type {}; + struct is_complete : detail::is_complete_helper, ODR_VIOLATION_PREVENTER>::type {}; + + template struct MetatypeDecay { using type = T; }; + template struct MetatypeDecay { using type = T; }; + template struct MetatypeDecay { using type = T; }; template struct IsPointerToTypeDerivedFromQObject @@ -2478,12 +2482,6 @@ QT_FOR_EACH_STATIC_CORE_POINTER(QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER) QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER) #undef QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER #endif -template -constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType() -{ - using Ty = std::remove_cv_t>; - return &QMetaTypeInterfaceWrapper::metaType; -} template struct qRemovePointerLike @@ -2510,14 +2508,26 @@ struct TypeAndForceComplete using ForceComplete = ForceComplete_; }; +template +constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType() +{ + using Ty = typename MetatypeDecay::type; + return &QMetaTypeInterfaceWrapper::metaType; +} + template constexpr const QMetaTypeInterface *qTryMetaTypeInterfaceForType() { using T = typename TypeCompletePair::type; using ForceComplete = typename TypeCompletePair::ForceComplete; - using Ty = std::remove_cv_t>; + using Ty = typename MetatypeDecay::type; using Tz = qRemovePointerLike_t; - if constexpr (!is_complete::value && !ForceComplete::value) { + + if constexpr (ForceComplete::value) { + return &QMetaTypeInterfaceWrapper::metaType; + } else if constexpr (std::is_reference_v) { + return nullptr; + } else if constexpr (!is_complete::value) { return nullptr; } else { return &QMetaTypeInterfaceWrapper::metaType; diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 79372484fb..54c9389862 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -477,8 +477,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) // Output parameters are references; type id not available typeName = QMetaType(type).name(); typeName.append('&'); + type = QMetaType::UnknownType; } - Q_ASSERT(type != QMetaType::UnknownType); int typeInfo; if (!typeName.isEmpty()) typeInfo = IsUnresolvedType | strings.enter(typeName);