From 1f2d756d92b9263fd823278cf417528cdc73685c Mon Sep 17 00:00:00 2001 From: Arno Rehn Date: Fri, 9 Jul 2021 14:29:47 +0200 Subject: Add QFutureInterfaceBase::get() to retrieve internals of QFuture For generic interop with other parts of Qt, we need to be able to extract the type-erased internal storage of QFuture. In particular, QtWebChannel needs this to transparently support QFuture as a method return type. Task-number: QTBUG-92903 Change-Id: I763f054656b8810d58720262d364baf42c47eb37 Reviewed-by: Konstantin Ritt Reviewed-by: Sona Kurazyan --- tests/auto/corelib/thread/qfuture/tst_qfuture.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index eff07ce309..8eadaee62a 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -163,6 +163,8 @@ private slots: void createReadyFutures(); + void getFutureInterface(); + private: using size_type = std::vector::size_type; @@ -3521,5 +3523,14 @@ void tst_QFuture::createReadyFutures() #endif } +void tst_QFuture::getFutureInterface() +{ + const int val = 42; + QFuture f = QtFuture::makeReadyFuture(val); + + auto interface = QFutureInterfaceBase::get(f); + QCOMPARE(interface.resultCount(), 1); +} + QTEST_MAIN(tst_QFuture) #include "tst_qfuture.moc" -- cgit v1.2.3