From df129c2449181869f0b95ae92d174b9eca52b2f7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Feb 2011 11:06:08 +0100 Subject: Add a mutex to protect the access to the QSet. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In theory, there should be no problems with doing this unlocked, as the test should only run one thread at a time in this particular code section. In practice, if the test is failing, multiple threads would be modifying the QSet. So the mutex is necessary to detect the test failing. Reviewed-By: Morten Sørvig --- .../auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index a6499ff..92e8608 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -201,6 +201,7 @@ void tst_QtConcurrentIterateKernel::noIterations() startThreadEngine(new IterateKernel(0, 0)).startBlocking(); } +QMutex threadsMutex; QSet threads; class ThrottleFor : public IterateKernel { @@ -219,8 +220,10 @@ public: QThread *thread = QThread::currentThread(); - if (begin > 140 && end < 160) + if (begin > 140 && end < 160) { + QMutexLocker locker(&threadsMutex); threads.insert(thread); + } if (100 >= begin && 100 < end) { throttling = true; -- cgit v0.12