Skip to content

Commit

Permalink
QThread: make it fatal to destroy a running QThread
Browse files Browse the repository at this point in the history
Align ourselves to what std::thread does (and what's sensible to do anyhow,
since we even document that "Deleting a running QThread [...] will probably
result in a program crash").

[ChangeLog][QtCore][QThread] Destroying a QThread which is still running will
now result in immediate and abnormal program termination.

Change-Id: Ib481287915be01a1381df14abf6e0fb68c36b5b5
Reviewed-by: David Faure <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
dangelog committed Jul 19, 2016
1 parent 091df96 commit c8277b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/corelib/thread/qthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent)
Note that deleting a QThread object will not stop the execution
of the thread it manages. Deleting a running QThread (i.e.
isFinished() returns \c false) will probably result in a program
isFinished() returns \c false) will result in a program
crash. Wait for the finished() signal before deleting the
QThread.
*/
Expand All @@ -418,7 +418,7 @@ QThread::~QThread()
locker.relock();
}
if (d->running && !d->finished && !d->data->isAdopted)
qWarning("QThread: Destroyed while thread is still running");
qFatal("QThread: Destroyed while thread is still running");

d->data->thread = 0;
}
Expand Down

0 comments on commit c8277b6

Please sign in to comment.