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

QFutureWatcher::resultReadyAt() signals sent in random order

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.8.0 FF
    • 6.4
    • Core: QtConcurrent
    • None
    • Linux/X11, macOS
    • 728c03ca7 (13.0), 63b2cf8a4 (dev), 933b606af (6.7), 7f3f29b7a (6.6), 56c388000 (master)

    Description

      Consider this test:

              QObject context;
              QFuture<QString> f = run([](QPromise<QString> &fi) {
                  fi.addResult("First");
                  fi.addResult("Second");
              });
              int count = 0;
              QString res;
              QFutureWatcher<QString> watcher;
              connect(&watcher, &QFutureWatcherBase::resultReadyAt,
                      &context, [&watcher, &count, &res](int index) {
                  ++count;
                  res = watcher.future().resultAt(index);
              });
              watcher.setFuture(f);
              f.waitForFinished();
              QCoreApplication::processEvents();
              QCOMPARE(count, 2);
              QCOMPARE(res, QString("Second"));
      

      It sometimes fails with:

         Actual   (res)              : "First"
         Expected (QString("Second")): "Second"
      

      Please see: https://codereview.qt-project.org/c/qt/qtbase/+/518638. The test fails on some platforms in CI.
      Spotted originally on MacOS MacOS_11 (clang-x86_64): https://testresults.qt.io/coin/integration/qt-creator/qt-creator/tasks/1704251436

      Attachments

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

        Activity

          People

            manordheim MÃ¥rten Nordheim
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes