summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2015-02-06 09:50:29 (GMT)
committerAndy Shaw <andy.shaw@digia.com>2015-02-08 11:48:28 (GMT)
commit97b85f4f4e7fc14ff47cd92e4525f7a56864bff4 (patch)
tree48cdc7e92aa52adafc76a963792fffbb5ae33887
parent6d5a2db97d6f19f4ccc446473adc40a922e1a7ea (diff)
downloadQt-97b85f4f4e7fc14ff47cd92e4525f7a56864bff4.zip
Qt-97b85f4f4e7fc14ff47cd92e4525f7a56864bff4.tar.gz
Qt-97b85f4f4e7fc14ff47cd92e4525f7a56864bff4.tar.bz2
QThread: fix race when setting the eventDispatcher
Use QMutexLocker to make this thread-safe. Task-number: QTBUG-29452 (cherry picked and adapted from qtbase/f4609b202208fe592d24c7ae3b4a48ee83045497) Change-Id: I5caf71d9a5dc6e3d655eac84426a0c5592772235 Reviewed-by: Louai Al-Khanji <louai.al-khanji@theqtcompany.com>
-rw-r--r--src/corelib/thread/qthread_symbian.cpp2
-rw-r--r--src/corelib/thread/qthread_unix.cpp3
-rw-r--r--src/corelib/thread/qthread_win.cpp2
3 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/thread/qthread_symbian.cpp b/src/corelib/thread/qthread_symbian.cpp
index 1d3376e..607e3ac 100644
--- a/src/corelib/thread/qthread_symbian.cpp
+++ b/src/corelib/thread/qthread_symbian.cpp
@@ -336,7 +336,9 @@ typedef void*(*QtThreadCallback)(void*);
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+ QMutexLocker l(&data->postEventList.mutex);
data->eventDispatcher = new QEventDispatcherSymbian;
+ l.unlock();
data->eventDispatcher->startingUp();
}
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 4d85968..7d8df26 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -273,6 +273,8 @@ typedef void*(*QtThreadCallback)(void*);
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+ QMutexLocker l(&data->postEventList.mutex);
+
#if defined(Q_OS_BLACKBERRY)
data->eventDispatcher = new QEventDispatcherBlackberry;
#else
@@ -286,6 +288,7 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data)
data->eventDispatcher = new QEventDispatcherUNIX;
#endif
+ l.unlock();
data->eventDispatcher->startingUp();
}
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 4ebae9e..01ddf02 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -318,7 +318,9 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
void QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+ QMutexLocker l(&data->postEventList.mutex);
data->eventDispatcher = new QEventDispatcherWin32;
+ l.unlock();
data->eventDispatcher->startingUp();
}