diff options
author | David Faure <david.faure@kdab.com> | 2013-03-18 15:19:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-22 16:44:51 +0100 |
commit | f4609b202208fe592d24c7ae3b4a48ee83045497 (patch) | |
tree | c9827efe74688595664c379085ba2a6267e49c13 /src/corelib/kernel/qsocketnotifier.cpp | |
parent | 85b25fc22176b574865813fa53f7eb2fcbdc89bf (diff) |
QThread: fix race when setting the eventDispatcher
Use QAtomicPointer to make this thread-safe.
Change-Id: If71f204699fcefabdb59bd26342d777d1cc9e2a7
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/kernel/qsocketnotifier.cpp')
-rw-r--r-- | src/corelib/kernel/qsocketnotifier.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index ad687491f1..e0c7f171c3 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -187,10 +187,10 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent) d->sntype = type; d->snenabled = true; - if (!d->threadData->eventDispatcher) { + if (!d->threadData->eventDispatcher.load()) { qWarning("QSocketNotifier: Can only be used with threads started with QThread"); } else { - d->threadData->eventDispatcher->registerSocketNotifier(this); + d->threadData->eventDispatcher.load()->registerSocketNotifier(this); } } @@ -273,12 +273,12 @@ void QSocketNotifier::setEnabled(bool enable) return; d->snenabled = enable; - if (!d->threadData->eventDispatcher) // perhaps application/thread is shutting down + if (!d->threadData->eventDispatcher.load()) // perhaps application/thread is shutting down return; if (d->snenabled) - d->threadData->eventDispatcher->registerSocketNotifier(this); + d->threadData->eventDispatcher.load()->registerSocketNotifier(this); else - d->threadData->eventDispatcher->unregisterSocketNotifier(this); + d->threadData->eventDispatcher.load()->unregisterSocketNotifier(this); } |