summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index e92be64dfa..cad7a14017 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -78,6 +78,13 @@ QThreadData::~QThreadData()
QThreadData::clearCurrentThreadData();
}
+ // ~QThread() sets thread to nullptr, so if it isn't null here, it's
+ // because we're being run before the main object itself. This can only
+ // happen for QAdoptedThread. Note that both ~QThreadPrivate() and
+ // ~QObjectPrivate() will deref this object again, but that is acceptable
+ // because this destructor is still running (the _ref sub-object has not
+ // been destroyed) and there's no reentrancy. The refcount will become
+ // negative, but that's acceptable.
QThread *t = thread;
thread = 0;
delete t;