From 8c4deff51c8064f5a15cae0342bfa66b6663662b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 21 Oct 2014 17:08:57 +0200 Subject: Fix QVariant associative container conversion from built-in types. Task-number: QTBUG-41403 Change-Id: I9dab0f9450cac11678eb6d20abd2dd08e86e0900 Reviewed-by: Stephen Kelly --- src/corelib/kernel/qmetatype.h | 15 +++++++++++++++ src/corelib/kernel/qvariant.h | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 3d859021b5..af38589903 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2109,6 +2109,21 @@ namespace QtPrivate { }; } +namespace QtMetaTypePrivate { +inline Q_DECL_CONSTEXPR bool isBuiltinSequentialType(int typeId) +{ + return typeId == qMetaTypeId() + || typeId == qMetaTypeId() + || typeId == qMetaTypeId(); +} + +inline Q_DECL_CONSTEXPR bool isBuiltinAssociativeType(int typeId) +{ + return typeId == qMetaTypeId() + || typeId == qMetaTypeId(); +} +} // QtMetaTypePrivate + QT_END_NAMESPACE #endif // QMETATYPE_H diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index bdbd0dd8ef..57e0523f7c 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -736,7 +736,7 @@ namespace QtPrivate { { static QVariantList invoke(const QVariant &v) { - if (v.userType() == qMetaTypeId() || v.userType() == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { + if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { QSequentialIterable iter = QVariantValueHelperInterface::invoke(v); QVariantList l; l.reserve(iter.size()); @@ -752,7 +752,7 @@ namespace QtPrivate { { static QVariantHash invoke(const QVariant &v) { - if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { + if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantHash l; l.reserve(iter.size()); @@ -768,7 +768,7 @@ namespace QtPrivate { { static QVariantMap invoke(const QVariant &v) { - if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { + if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId())) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) -- cgit v1.2.3