From f052cefc2fd223605a59c1eec4e53a71ddbfee39 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 26 Mar 2013 16:28:08 +0100 Subject: tst_qthread: fix race on "bool visited" Change-Id: I438bad9a4f8afb76272c8d8f08461a6d2c9a0b18 Reviewed-by: Olivier Goffart --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 8 ++++---- 1 file 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 weak_ed(ed); QVERIFY(!weak_ed.isNull()); -- cgit v1.2.3