From c8277b6e5322da5fa74cf81e295c8ed71beb1624 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 16 Jul 2016 14:43:50 +0200 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 4aac24f454a..7118ad5c9bd 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -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. */ @@ -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; }