summaryrefslogtreecommitdiff
path: root/tests/auto/qtconcurrentiteratekernel
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-02-16 11:06:08 +0100
committerThiago Macieira <thiago.macieira@nokia.com>2011-02-16 11:32:06 +0100
commitdf129c2449181869f0b95ae92d174b9eca52b2f7 (patch)
treef8546da86329e16619d6da735cf8fcb2cc47d388 /tests/auto/qtconcurrentiteratekernel
parent89b754d30eaa5c9c57fb50bc563a3c60cc314c4e (diff)
downloadqt4-tools-df129c2449181869f0b95ae92d174b9eca52b2f7.tar.gz
Add a mutex to protect the access to the QSet.
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
Diffstat (limited to 'tests/auto/qtconcurrentiteratekernel')
-rw-r--r--tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
index a6499ff511..92e8608b5b 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<TestIterator, void>(0, 0)).startBlocking();
}
+QMutex threadsMutex;
QSet<QThread *> threads;
class ThrottleFor : public IterateKernel<TestIterator, void>
{
@@ -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;