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

QThread::exec always returns immediately, if QThread::exit has been called when event loop was not running.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 4.7.2
    • 4.7.0, 4.7.1
    • Core: Threads
    • None
    • Have tried on Gentoo Linux 64bit, Ubuntu Linux 32bit, Windows 7 32bit
    • 202433ee1fd377ac36dc55fb466b9fc616b4d4fd

      It is impossible to get a running thread into its event loop if exit has been called when the event loop was not running.

      In earlier versions, calling exit when the thread's event loop was not running, had no effect, and I can not imagine why this should have been changed by design. Maybe I'm wrong?

      Attached is a small program that demonstrates the problem: A worker thread waits in its event loop for something to do. When work arrives, in the form of a call to the work function, exit is called and the thread wakes up, works for a while, and then calls exec and thus returns to waiting state.

      If the work function is only called when the thread is in exec, everything works fine, but if the work function is called too frequently, so that exit is called while the thread is "working", the thread can never enter its event loop again.

      Try changing the spinbox value, first slowly, and then quickly, while observing the console output, to see the problem.

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

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            morten71 Morten Højer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes