tst_qthread: fix race on "bool visited"

Change-Id: I438bad9a4f8afb76272c8d8f08461a6d2c9a0b18
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
bb10
David Faure 2013-03-26 16:28:08 +01:00 committed by The Qt Project
parent 6c10f5203b
commit f052cefc2f
1 changed files with 4 additions and 4 deletions

View File

@ -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());