From f4609b202208fe592d24c7ae3b4a48ee83045497 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 18 Mar 2013 15:19:44 +0100 Subject: QThread: fix race when setting the eventDispatcher Use QAtomicPointer to make this thread-safe. Change-Id: If71f204699fcefabdb59bd26342d777d1cc9e2a7 Reviewed-by: Olivier Goffart --- src/corelib/thread/qthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/thread/qthread.cpp') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index dd4d4e74ae4..d230c8a1456 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -752,7 +752,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent) QAbstractEventDispatcher *QThread::eventDispatcher() const { Q_D(const QThread); - return d->data->eventDispatcher; + return d->data->eventDispatcher.load(); } /*! @@ -767,7 +767,7 @@ QAbstractEventDispatcher *QThread::eventDispatcher() const void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) { Q_D(QThread); - if (d->data->eventDispatcher != 0) { + if (d->data->hasEventDispatcher()) { qWarning("QThread::setEventDispatcher: An event dispatcher has already been created for this thread"); } else { eventDispatcher->moveToThread(this); -- cgit v1.2.3