summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-03-25 18:15:39 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-03-28 13:21:02 (GMT)
commit0ee221b374ffef3657247be4c78e05689e04bef7 (patch)
treeed422aeaeca48be516e2a87867d0f7ca89c080a2 /src/corelib/thread/qthread.cpp
parent383da4084ae0cd8dcb9777cbfa90a55c56f7ad09 (diff)
downloadQt-0ee221b374ffef3657247be4c78e05689e04bef7.zip
Qt-0ee221b374ffef3657247be4c78e05689e04bef7.tar.gz
Qt-0ee221b374ffef3657247be4c78e05689e04bef7.tar.bz2
Fix the leak of QAdoptedThread and all dependent objects
if there is a QEventDispatcher in QAdoptedThread. QAdoptedThread is supposed to be destroyed when the QThreadData is destroyed. But QThreadData is ref-counted, and QEventDispatcher holds a reference to it. QEventDispatcher is supposed to be destroyed in QThreadPrivate::finish, which is supposed to be called from the destructor of QAdoptedThread. There is a circular dependence. We break it by calling finish in the callback that is called when the thread is finished. Task-number: QTBUG-17986 Reviewed-by: Brad
Diffstat (limited to 'src/corelib/thread/qthread.cpp')
-rw-r--r--src/corelib/thread/qthread.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 326f494..817e73e 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
QThreadData::QThreadData(int initialRefCount)
: _ref(initialRefCount), thread(0),
- quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true)
+ quitNow(false), loopLevel(0), eventDispatcher(0), canWait(true), isAdopted(false)
{
// fprintf(stderr, "QThreadData %p created\n", this);
}
@@ -150,7 +150,7 @@ QAdoptedThread::QAdoptedThread(QThreadData *data)
QAdoptedThread::~QAdoptedThread()
{
#ifndef QT_NO_THREAD
- QThreadPrivate::finish(this);
+// QThreadPrivate::finish(this);
#endif
// fprintf(stderr, "~QAdoptedThread = %p\n", this);
}
@@ -409,7 +409,7 @@ QThread::~QThread()
wait();
locker.relock();
}
- if (d->running && !d->finished)
+ if (d->running && !d->finished && !d->data->isAdopted)
qWarning("QThread: Destroyed while thread is still running");
d->data->thread = 0;