diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-10-16 12:11:48 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-10-19 13:18:07 +0200 |
commit | 0ebd05686d97c9282f148a18cab32fb079abdbc7 (patch) | |
tree | c66311ea96834b95ea32b74084b222d9e8ba48b0 /tests | |
parent | 4cf9168630a7fdc79d11499190c221863fe2c819 (diff) |
tst_QThreadPool: fix memleak
Benign, but easy to avoid by using the same pattern as in clear().
Change-Id: Ie382313343385f0709519b232a7d58dd8181b8de
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index f6bdb6c53b..9c2c8bf12a 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -906,11 +906,12 @@ void tst_QThreadPool::waitForDone() void tst_QThreadPool::waitForDoneTimeout() { + QMutex mutex; class BlockedTask : public QRunnable { public: - QMutex mutex; - BlockedTask() { setAutoDelete(false); } + QMutex &mutex; + explicit BlockedTask(QMutex &m) : mutex(m) {} void run() { @@ -922,11 +923,10 @@ void tst_QThreadPool::waitForDoneTimeout() QThreadPool threadPool; - BlockedTask *task = new BlockedTask; - task->mutex.lock(); - threadPool.start(task); + mutex.lock(); + threadPool.start(new BlockedTask(mutex)); QVERIFY(!threadPool.waitForDone(100)); - task->mutex.unlock(); + mutex.unlock(); QVERIFY(threadPool.waitForDone(400)); } |