Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97582

QFuture::cancel through then()/onCanceled/onFailed

    XMLWordPrintable

Details

    • 8
    • Team 1 Foundation_Sprint 46

    Description

      I would have expected something like this to work:

      QPromise<int> p;
      auto f = p.future().then([](int i){ return i; }).onCanceled([]{ qDebug("canceled"); return -1; });
      p.start();
      f.cancel();
      p.addResult(1);
      p.finish();
      f.result();
      

      But it just hangs in the result() and onCanceled handler is not called.

      This works however:

      QPromise<int> p;
      auto original = p.future();
      auto f = original.then([](int i){ return i; }).onCanceled([]{ qDebug("canceled"); return -1; });
      p.start();
      original.cancel();
      p.addResult(1);
      p.finish();
      f.result();
      

      So it looks like cancel() call to the future returned by then/onCanceled/onFailed does not propagate to the original QFuture.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sonakur Sona Kurazyan
            poikelin Joni Poikelin
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: