diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2019-05-28 11:22:40 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-05-28 11:22:40 +0200 |
commit | 7abcc491fac43a17ff6c9e1de0c7646961690849 (patch) | |
tree | b9b0b5a69d4dcf5232f36ddc3a8f1f5f3e7dd204 | |
parent | 6031bd7bfdf97c492f9f11b4bd0a5375613b55de (diff) | |
parent | cbb8fc1ae374e2b25c733e3f15109fb407e0cf95 (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/webchannel/qmetaobjectpublisher.cpp
Change-Id: I853b8fc7270847c1a9cdd862dff278ddb2533e92
-rw-r--r-- | src/webchannel/qmetaobjectpublisher.cpp | 5 | ||||
-rw-r--r-- | tests/auto/webchannel/tst_webchannel.cpp | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index 9f5e9cd..102cbda 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -781,7 +781,10 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA #endif } else if (result.canConvert<QVariantList>()) { // recurse and potentially wrap contents of the array - return wrapList(result.toList(), transport); + // *don't* use result.toList() as that *only* works for QVariantList and QStringList! + // Also, don't use QSequentialIterable (yet), since that seems to trigger QTBUG-42016 + // in certain cases. + return wrapList(result.value<QVariantList>(), transport); } else if (result.canConvert<QVariantMap>()) { // recurse and potentially wrap contents of the map return wrapMap(result.toMap(), transport); diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp index 4e622c7..ffaebba 100644 --- a/tests/auto/webchannel/tst_webchannel.cpp +++ b/tests/auto/webchannel/tst_webchannel.cpp @@ -827,6 +827,13 @@ void TestWebChannel::testWrapValues() QVERIFY(value.isDouble()); QCOMPARE(value.toInt(), (int) flags); } + { + QVector<int> vec{1, 2, 3}; + QVariant variant = QVariant::fromValue(vec); + QJsonValue value = channel.d_func()->publisher->wrapResult(variant, m_dummyTransport); + QVERIFY(value.isArray()); + QCOMPARE(value.toArray(), QJsonArray({1, 2, 3})); + } } void TestWebChannel::testWrapObjectWithMultipleTransports() |