diff options
author | David Faure <david.faure@kdab.com> | 2013-03-26 16:28:08 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-29 15:16:47 +0100 |
commit | f052cefc2fd223605a59c1eec4e53a71ddbfee39 (patch) | |
tree | b4f4562d940fb5adf5c68c6126fabee253f96971 /tests/auto/corelib/thread/qthread | |
parent | 6c10f5203bae33992b676df50636eacae9f79b88 (diff) |
tst_qthread: fix race on "bool visited"
Change-Id: I438bad9a4f8afb76272c8d8f08461a6d2c9a0b18
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/corelib/thread/qthread')
-rw-r--r-- | tests/auto/corelib/thread/qthread/tst_qthread.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 7fbb5e9f5f..1ee628dde5 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1221,9 +1221,9 @@ QT_END_NAMESPACE class DummyEventDispatcher : public QAbstractEventDispatcher { public: - DummyEventDispatcher() : QAbstractEventDispatcher(), visited(false) {} + DummyEventDispatcher() : QAbstractEventDispatcher() {} bool processEvents(QEventLoop::ProcessEventsFlags) { - visited = true; + visited.store(true); emit awake(); QCoreApplication::sendPostedEvents(); return false; @@ -1247,7 +1247,7 @@ public: void unregisterEventNotifier(QWinEventNotifier *) { } #endif - bool visited; + QBasicAtomicInt visited; // bool }; class ThreadObj : public QObject @@ -1285,7 +1285,7 @@ void tst_QThread::customEventDispatcher() QMetaObject::invokeMethod(&obj, "visit", Qt::QueuedConnection); loop.exec(); // test that the ED has really been used - QVERIFY(ed->visited); + QVERIFY(ed->visited.load()); QPointer<DummyEventDispatcher> weak_ed(ed); QVERIFY(!weak_ed.isNull()); |