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

QFutureWatcher::isFinished() stays false after waitForFinished()

    XMLWordPrintable

Details

    • All
    • 3
    • 53e4a50c6b3c7359b9afc24f30c9517abdf9561a (qt/qtbase/dev) f20f5b722fd497980e22ef6b1ca5053eac06b251 (qt/qtbase/6.2) c4012ff5f08c02840ef42216e1273b08e6bf5234 (qt/qtbase/6.1)
    • Qt6_Foundation_Sprint 38

    Description

      The documentation says "QFutureWatcher::isFinished() Returns true if the asynchronous computation represented by the future() has finished".

      From reading this, I assume that calling watcher.isFinished() is equivalent to watcher.future().isFinished(). But it's not. The watcher only becomes finished after the control-flow has been given back to the event loop, so that the "finished event" can be consumed by the watcher. IMO, this is an important detail. And it has driven me crazy while trying to figure out why the watcher in my app isn't emitting any signals.

      Please, either mention this behavior explicitly in the docs, or change the implementation so that watcher.isFinished() becomes equivalent to watcher.future().isFinished().

      Steps to reproduce:

       

      QFutureWatcher<int> watcher;
      QFuture<int> fut = startSomethingAsync();
      watcher.setFuture(fut);
      watcher.waitForFinished();
      bool l = fut.isFinished(); // true
      l = wat.future().isFinished(); // true
      l = wat.isFinished(); // false??
      

       

      Attachments

        For Gerrit Dashboard: QTBUG-91048
        # Subject Branch Project Status CR V

        Activity

          People

            sonakur Sona Kurazyan
            derselbst Tom M
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes