From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetatype.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/kernel/qmetatype.cpp') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 356a675517..3f0b8900e4 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1113,8 +1113,8 @@ static int registerNormalizedType(const NS(QByteArray) &normalizedTypeName, QCustomTypeInfo inf; inf.typeName = normalizedTypeName; #ifndef QT_NO_DATASTREAM - inf.loadOp = 0; - inf.saveOp = 0; + inf.loadOp = nullptr; + inf.saveOp = nullptr; #endif inf.alias = -1; inf.typedConstructor = typedConstructor; @@ -1955,7 +1955,7 @@ public: return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject : nullptr; - return 0; + return nullptr; } }; -- cgit v1.2.3 From 4c3c63d4cbb81b38e88e06b72749e7e01497b6f1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Dec 2019 09:49:34 +0100 Subject: QMetaType: add more static-less API In prevision to Qt6 which is going to discourrage the use of the integer id, add some missing API to the staticless QMetaType API: - Add a way to construct a QMetaType from a type without calling qMetaTypeId: QMetaType::fromType() - Add equality operators - Add a QMetaType::name() function - Add a default constructor (by adding a default parameter to the existing ctor) Change-Id: I95487c1c31bdf0d773717daa9d5452cbced30673 Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetatype.cpp | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qmetatype.cpp') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 3f0b8900e4..af9a2e0dd2 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -506,6 +506,31 @@ struct DefinedTypesFilter { Destructs this object. */ +/*! + \fn template QMetaType QMetaType::fromType() + \since 5.15 + + Returns the QMetaType corresponding to the type in the template parameter. +*/ + +/*! \fn bool operator==(const QMetaType &a, const QMetaType &b) + \since 5.15 + \relates QMetaType + \overload + + Returns \c true if the QMetaType \a a represents the same type + as the QMetaType \a b, otherwise returns \c false. +*/ + +/*! \fn bool operator!=(const QMetaType &a, const QMetaType &c) + \since 5.15 + \relates QMetaType + \overload + + Returns \c true if the QMetaType \a a represents a difference type + than the QMetaType \a b, otherwise returns \c false. +*/ + #define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName) \ { #RealName, sizeof(#RealName) - 1, MetaTypeId }, @@ -930,7 +955,7 @@ constexpr MetaTypeOffsets:: pointer if no matching type was found. The returned pointer must not be deleted. - \sa type(), isRegistered(), Type + \sa type(), isRegistered(), Type, name() */ const char *QMetaType::typeName(int typeId) { @@ -950,6 +975,20 @@ const char *QMetaType::typeName(int typeId) #undef QT_METATYPE_TYPEID_TYPENAME_CONVERTER } +/*! + \since 5.15 + + Returns the type name associated with this QMetaType, or a null + pointer if no matching type was found. The returned pointer must not be + deleted. + + \sa typeName() +*/ +QByteArray QMetaType::name() const +{ + return QMetaType::typeName(m_typeId); +} + /* Similar to QMetaType::type(), but only looks in the static set of types. */ @@ -2214,6 +2253,8 @@ QMetaType QMetaType::typeInfo(const int type) \since 5.0 Constructs a QMetaType object that contains all information about type \a typeId. + + \note: The default parameter was added in Qt 5.15 */ QMetaType::QMetaType(const int typeId) : m_typeId(typeId) -- cgit v1.2.3