summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2021-07-09 16:22:18 +0200
committerArno Rehn <a.rehn@menlosystems.com>2021-07-15 17:06:54 +0200
commit90d9a86c2e762c9426d0facbd54ed5dbff574ecd (patch)
tree03481f31a0bdc3c7593af8fb3ca71e167c3bf345 /tests/auto/corelib/thread
parentac40875ba701d2f5d405bbd652fbe699f074236c (diff)
QMetaType: Support converting any QFuture<T> to QFuture<void>
QMetaType now implicitly knows how to convert any QFuture<T> to QFuture<void> without needing to manually register a converter function. QtWebChannel will make use of this to transparently support QFuture<T> return types. [ChangeLog][QtCore][QMetaType] QMetaType now supports converting any QFuture<T> to QFuture<void>. Task-number: QTBUG-92903 Change-Id: Ied7e71be37c346cc3d2c274ffb0d91a6821ab4d4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/corelib/thread')
-rw-r--r--tests/auto/corelib/thread/qfuture/tst_qfuture.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
index 8eadaee62a..af83ee3b95 100644
--- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
+++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp
@@ -164,6 +164,7 @@ private slots:
void createReadyFutures();
void getFutureInterface();
+ void convertQMetaType();
private:
using size_type = std::vector<int>::size_type;
@@ -3532,5 +3533,22 @@ void tst_QFuture::getFutureInterface()
QCOMPARE(interface.resultCount(), 1);
}
+void tst_QFuture::convertQMetaType()
+{
+ const auto intType = QMetaType::fromType<QFuture<int>>();
+ const auto voidType = QMetaType::fromType<QFuture<void>>();
+
+ QVERIFY(QMetaType::canConvert(intType, voidType));
+
+ const int val = 42;
+ QFuture<int> f = QtFuture::makeReadyFuture(val);
+ auto variant = QVariant::fromValue(f);
+ QVERIFY(variant.convert(voidType));
+
+ const auto voidFuture = variant.value<QFuture<void>>();
+ QVERIFY(voidFuture.isValid());
+ QVERIFY(voidFuture.isFinished());
+}
+
QTEST_MAIN(tst_QFuture)
#include "tst_qfuture.moc"