summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-10-21 17:08:57 +0200
committerJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-10-24 16:27:42 +0200
commit8c4deff51c8064f5a15cae0342bfa66b6663662b (patch)
treeaf53315891fcb8fec0397e03450c2e9c1802ed3a /src/corelib
parent9c92a18b975173383454c13d34f4438636f0450c (diff)
Fix QVariant associative container conversion from built-in types.
Task-number: QTBUG-41403 Change-Id: I9dab0f9450cac11678eb6d20abd2dd08e86e0900 Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qmetatype.h15
-rw-r--r--src/corelib/kernel/qvariant.h6
2 files changed, 18 insertions, 3 deletions
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<QStringList>()
+ || typeId == qMetaTypeId<QByteArrayList>()
+ || typeId == qMetaTypeId<QVariantList>();
+}
+
+inline Q_DECL_CONSTEXPR bool isBuiltinAssociativeType(int typeId)
+{
+ return typeId == qMetaTypeId<QVariantHash>()
+ || typeId == qMetaTypeId<QVariantMap>();
+}
+} // 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<QStringList>() || v.userType() == qMetaTypeId<QByteArrayList>() || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::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<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::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<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
QVariantMap l;
for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)