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

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.9.4
    • Fix Version/s: 5.12.3, 5.14.0 Alpha
    • Component/s: Core: Event loop
    • Labels:
      None
    • Platform/s:
      Windows
    • Commits:
      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

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

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            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