diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-01-30 14:37:36 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-30 18:49:27 +0100 |
commit | a4ab8d0bbc4075e90547dac9df91a4cfac93942a (patch) | |
tree | 8bfa2f462ccad88a7ac4f1f229a1036ba2ef4dc2 /src/corelib/json | |
parent | 34e8dd5d6f250463194e9b7a0f63e7e021ec8d6b (diff) |
Add a null pointer check to QJsonObject::toVariantMap
If the object is null, simply return an empty variant map.
Added another test case checking conversion from QJsonArray
to a QVariantList.
Change-Id: Ieccd163e76630f7db7f41255acd9d1baf66bb38d
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Kevin Simons <kevin.simons@nokia.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r-- | src/corelib/json/qjsonobject.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index 22c5dbfa91..86b4e2cb0a 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -158,9 +158,11 @@ QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) QVariantMap QJsonObject::toVariantMap() const { QVariantMap map; - for (uint i = 0; i < o->length; ++i) { - QJsonPrivate::Entry *e = o->entryAt(i); - map.insert(e->key(), QJsonValue(d, o, e->value).toVariant()); + if (o) { + for (uint i = 0; i < o->length; ++i) { + QJsonPrivate::Entry *e = o->entryAt(i); + map.insert(e->key(), QJsonValue(d, o, e->value).toVariant()); + } } return map; } |