diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2021-07-09 14:29:47 +0200 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2021-07-12 18:33:19 +0200 |
commit | 1f2d756d92b9263fd823278cf417528cdc73685c (patch) | |
tree | 5ddf471534ffb805e81b3e7af1dd1dc72337f4cb /tests/auto/corelib | |
parent | 82bc752497a261669dc22e028e87c043d99355a4 (diff) |
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<T>. In particular,
QtWebChannel needs this to transparently support QFuture<T> as a method
return type.
Task-number: QTBUG-92903
Change-Id: I763f054656b8810d58720262d364baf42c47eb37
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/thread/qfuture/tst_qfuture.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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<int>::size_type; @@ -3521,5 +3523,14 @@ void tst_QFuture::createReadyFutures() #endif } +void tst_QFuture::getFutureInterface() +{ + const int val = 42; + QFuture<int> f = QtFuture::makeReadyFuture(val); + + auto interface = QFutureInterfaceBase::get(f); + QCOMPARE(interface.resultCount(), 1); +} + QTEST_MAIN(tst_QFuture) #include "tst_qfuture.moc" |