diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-10 14:25:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-11 21:10:54 +0000 |
commit | b3f7bea10525a0b05a61f151f684b63d66488193 (patch) | |
tree | 98e4994256f91d31891c739dbfadb3627bcdfb7b /src/corelib/kernel/qvariant.cpp | |
parent | b783c03d19d892c5e92c859ff0265061106cfa77 (diff) |
Handle conversion and comparison between qvarianthash and qvariantmap
QVariant claims to be able to QVariantHash and QVariantMap, but the
actual conversion implementation is missing.
Task-number: QTBUG-61471
Change-Id: I0cba74642aa77dc423effed289bc7619922a89eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f114a84d22..e6262124fb 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -855,6 +855,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) { *static_cast<QVariantMap *>(result) = *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr); + } else if (d->type == QVariant::Hash) { + QVariantMap *map = static_cast<QVariantMap *>(result); + const QVariantHash *hash = v_cast<QVariantHash>(d); + const auto end = hash->end(); + for (auto it = hash->begin(); it != end; ++it) + map->insertMulti(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QJsonValue) { if (!v_cast<QJsonValue>(d)->isObject()) @@ -871,6 +877,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) { *static_cast<QVariantHash *>(result) = *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr); + } else if (d->type == QVariant::Map) { + QVariantHash *hash = static_cast<QVariantHash *>(result); + const QVariantMap *map = v_cast<QVariantMap>(d); + const auto end = map->end(); + for (auto it = map->begin(); it != end; ++it) + hash->insertMulti(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QJsonValue) { if (!v_cast<QJsonValue>(d)->isObject()) |