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

exit() or quit() called before start() prevents starting of a thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.7.2
    • 4.7.0
    • Core: Threads
    • None
    • Windows XP SP3
      Qt 4.7
      Visual Studio 2008 Version 9.0.30729.1 SP
    • b93947f5a25b3cc021518b944dc96b892f672bd3

      If I call QThread::quit() or QThread::exit() (which is pretty much same) before actual running of an instance of QThread it will spoil the message loop forcing it to exit immediately. It seems wrong because exit() as a regular member function must not affect the thread in the not running state and quit() as a regular slot must not keep/remember an incoming signal if there's no message loop in the current object.
      It's easy to reproduce:

      MyThread thread;
      thread.exit(555); // or quit()
      thread.start();
      ...
      MyThread::run()
      {
        QThread::exec(); // exits immediately with exit code 555 or 0 in case of quit()
      }
      

      Full example is attached.

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

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            leonty leonty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes