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

[Reg 6.5 -> 6.6] Calling QPromise::finish() from the same thread deadlocks i

    XMLWordPrintable

Details

    • 59e21a536 (dev), f89d80c90 (6.7), d5528cdec (6.6)

    Description

      Code

      #include <QCoreApplication>
      #include <QFuture>
      #include <QTimer>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
      
          QPromise<QString> promise;
          promise.start();
      
          // Wait 1 second and then complete the task
          QTimer::singleShot(1000, &app, [&] {
              promise.addResult("Task is complete");
              qDebug("Finishing...");
              promise.finish();
              qDebug("...finished!");
          });
      
          promise.future().then(&app, [](const QString& result) {
              qDebug() << "Future lambda:" << result;
              qApp->quit();
          });
      
          return app.exec();
      }
      

       

      Expected outcomes (Qt 6.5.3)
      Console prints the following, and the app quits:

      Finishing...
      Future lambda: "Task is complete"
      ...finished!
      

       

      Actual outcomes (Qt 6.6.1)
      Console prints the following, and the app becomes unresponsive indefinitely:

      Finishing...
      

      Attachments

        Issue Links

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

          Activity

            People

              ivan.solovev Ivan Solovev
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes