-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
6.9.1
-
None
There are two issues here:
- is described in the attached example.
- also about canceling chained qfutures, but is a bit tricky, let me give you an example for better understanding:
QFuture<int> cancelableOperation() { QPromise<int> promise{QFutureInterface<int>{QFutureInterfaceBase::State::Pending}}; QFuture<int> future = promise.future(); auto leakingThread = QThread::create( [](QPromise<int> promise) { promise.start(); QThread::sleep(1); Q_ASSERT(promise.isCanceled()); promise.addResult(42); promise.finish(); }, std::move(promise)); leakingThread->start(); return future; } int main(int argc, char *argv[]) { auto chainedFutures = cancelableOperation() .then([](int value) { Q_ASSERT(false); }) .onCanceled([] { Q_ASSERT(true); }); QThread::msleep(500); chainedFutures.cancel(); chainedFutures.waitForFinished(); return 0; }
The expectation for 2. is that chainedFutures.cancel(); will cancel also cancelableOperation.
Each example has Q_ASSERTS which should pass.