summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-18 03:02:09 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-05-18 03:02:09 +0200
commitcbb8fc1ae374e2b25c733e3f15109fb407e0cf95 (patch)
tree5d0d95f78f789c58c2a2eefadd681bbdf531a4db
parent11c8706b6c0ca3f9c0d195641fd0eea816899acd (diff)
parent1466130070922a6cc55c2a5b724311780a394a13 (diff)
downloadqtwebchannel-cbb8fc1ae374e2b25c733e3f15109fb407e0cf95.tar.gz
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I182d51367aed4518f5bbc247e4e517af09028f7a
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp5
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index c9285b7..a77072b 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -619,7 +619,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);
}
return QJsonValue::fromVariant(result);
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 9a0f575..133655d 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -797,6 +797,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()