QThread: make it fatal to destroy a running QThread
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 <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
091df96fb8
commit
c8277b6e53
@ -403,7 +403,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent)
|
|||||||
|
|
||||||
Note that deleting a QThread object will not stop the execution
|
Note that deleting a QThread object will not stop the execution
|
||||||
of the thread it manages. Deleting a running QThread (i.e.
|
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
|
crash. Wait for the finished() signal before deleting the
|
||||||
QThread.
|
QThread.
|
||||||
*/
|
*/
|
||||||
@ -418,7 +418,7 @@ QThread::~QThread()
|
|||||||
locker.relock();
|
locker.relock();
|
||||||
}
|
}
|
||||||
if (d->running && !d->finished && !d->data->isAdopted)
|
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;
|
d->data->thread = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user