diff options
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 3 | ||||
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 18 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index b28597468f..2907cb66ae 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -60,6 +60,9 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcCheckIndex, "qt.core.qabstractitemmodel.checkindex") +int qRegisterNormalizedMetaType_QList_QModelIndex(const QByteArray &name) +{ return qRegisterNormalizedMetaTypeImplementation<QList<QModelIndex>>(name); } + QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex &index) { Q_ASSERT(index.isValid()); // we will _never_ insert an invalid index in the list diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index a059036d12..a8d8a7de4b 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -537,6 +537,10 @@ inline Qt::ItemFlags QModelIndex::flags() const inline size_t qHash(const QModelIndex &index, size_t seed = 0) noexcept { return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; } +Q_CORE_EXPORT int qRegisterNormalizedMetaType_QList_QModelIndex(const QByteArray &name); +template <> inline int qRegisterNormalizedMetaType<QList<QModelIndex>>(const QByteArray &name) +{ return qRegisterNormalizedMetaType_QList_QModelIndex(name); } + QT_END_NAMESPACE Q_DECLARE_METATYPE(QModelIndexList) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index dd37ab2fa1..cff94d3324 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1226,7 +1226,7 @@ namespace QtPrivate { } template <typename T> -int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName) +int qRegisterNormalizedMetaTypeImplementation(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName) { #ifndef QT_NO_QOBJECT Q_ASSERT_X(normalizedTypeName == QMetaObject::normalizedType(normalizedTypeName.constData()), @@ -1254,6 +1254,22 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz return id; } +// This primary template calls the -Implementation, like all other specialisations should. +// But the split allows to +// - in a header: +// - declare, but not define, a specialization of this template +// - add an explicit instantiation declaration (extern template ...) +// - in the .cpp file: +// - define the specialization to call the -Implementation +// - add an explicit instantiation definition +// This prevents the compiler from taking the leeway for inline functions in +// [temp.explicit]/13 Note 4 +template <typename T> +int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName) +{ + return qRegisterNormalizedMetaTypeImplementation<T>(normalizedTypeName); +} + template <typename T> int qRegisterMetaType(const char *typeName) { |