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

calling QEventLoop::exit() from a different thread doesn't always exit the eventloop

    XMLWordPrintable

Details

    • Windows
    • 197029b3d23237e61311019de1b63e3ce6720ed5 (qt/qtbase/5.12)

    Description

      Suppose you started a local run of a QEventLoop in some thread:

      // thread1

      QEventLoop loop;

      loop.exec();

       

      and you want to exit it from a different thread like this:

      // thread2 gets a reference to the loop variable somehow

      loopFromThread1.exit(0);

       

      then the loop does not always exit.

      The issue seems to be caused by the fact that the interrupt variable in QEventDispatcherWin32Private is a normal bool and not an atomic.
      The change of the Boolean to false by the interrupt() call by QEventLoop::exit() is not always seen by the thread running the loop.

      The same member has been turned into a QAtomicInt in QEventDispatcherUNIXPrivate by the following commit:

      Ieffaa169eb67f40dc935291b3994f9ff1c7e05f0

      https://codereview.qt-project.org/#/c/51060/

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            bta Bart Tanghe
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes